-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' into patch-3
- Loading branch information
Showing
197 changed files
with
5,379 additions
and
1,733 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
app/code/Magento/Catalog/Model/Category/LayoutCacheTagResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
/************************************************************************ | ||
* | ||
* Copyright 2024 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
* ************************************************************************ | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Category; | ||
|
||
use Magento\Catalog\Model\Category; | ||
use Magento\Framework\App\Cache\Tag\StrategyInterface; | ||
use Magento\Framework\Model\AbstractModel; | ||
use Magento\Widget\Model\Widget\Instance; | ||
|
||
/** | ||
* Get additional layout cache tag for category layout. | ||
*/ | ||
class LayoutCacheTagResolver implements StrategyInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getTags($object) | ||
{ | ||
if ($this->isExistingCategoryLayoutChange($object)) { | ||
return [ | ||
str_replace('{{ID}}', (string) $object->getId(), Instance::SINGLE_CATEGORY_LAYOUT_HANDLE) | ||
]; | ||
} | ||
return []; | ||
} | ||
|
||
/** | ||
* Check if existing category page layout change | ||
* | ||
* @param Category $object | ||
* @return bool | ||
*/ | ||
private function isExistingCategoryLayoutChange(Category $object): bool | ||
{ | ||
return !$object->isObjectNew() && $this->isObjectChanged($object); | ||
} | ||
|
||
/** | ||
* Check if the page layout of the given category is changed | ||
* | ||
* @param AbstractModel $object | ||
* @return bool | ||
*/ | ||
private function isObjectChanged(AbstractModel $object): bool | ||
{ | ||
$isChanged = false; | ||
$objectNewPageLayout = $object->getData('page_layout'); | ||
$objectOldPageLayout = $object->getOrigData('page_layout'); | ||
if ($objectNewPageLayout !== 'empty' && | ||
$objectNewPageLayout !== $objectOldPageLayout | ||
) { | ||
$isChanged = true; | ||
} | ||
return $isChanged; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
app/code/Magento/Catalog/Model/Product/LayoutCacheTagResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
/************************************************************************ | ||
* | ||
* Copyright 2024 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
* ************************************************************************ | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Product; | ||
|
||
use Magento\Catalog\Model\Product; | ||
use Magento\Framework\App\Cache\Tag\StrategyInterface; | ||
use Magento\Framework\Model\AbstractModel; | ||
use Magento\Widget\Model\Widget\Instance; | ||
|
||
/** | ||
* Get additional layout cache tag for product layout. | ||
*/ | ||
class LayoutCacheTagResolver implements StrategyInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function getTags($object) | ||
{ | ||
if ($this->isExistingProductLayoutChange($object)) { | ||
return [ | ||
str_replace('{{ID}}', (string) $object->getId(), Instance::SINGLE_PRODUCT_LAYOUT_HANDLE) | ||
]; | ||
} | ||
return []; | ||
} | ||
|
||
/** | ||
* Check if existing Product page layout change | ||
* | ||
* @param Product $object | ||
* @return bool | ||
*/ | ||
private function isExistingProductLayoutChange(Product $object): bool | ||
{ | ||
return !$object->isObjectNew() && $this->isObjectChanged($object); | ||
} | ||
|
||
/** | ||
* Check if the page layout of the given product is changed | ||
* | ||
* @param AbstractModel $object | ||
* @return bool | ||
*/ | ||
private function isObjectChanged(AbstractModel $object): bool | ||
{ | ||
$isChanged = false; | ||
$objectNewPageLayout = $object->getData('page_layout'); | ||
$objectOldPageLayout = $object->getOrigData('page_layout'); | ||
if ($objectNewPageLayout !== 'empty' && | ||
$objectNewPageLayout !== $objectOldPageLayout | ||
) { | ||
$isChanged = true; | ||
} | ||
return $isChanged; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.