-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix issue with large number of identities
- Loading branch information
1 parent
9b85382
commit 1a420e4
Showing
4 changed files
with
44 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
/** | ||
* Copyright © Magefan (support@magefan.com). All rights reserved. | ||
* See LICENSE.txt for license details (http://opensource.org/licenses/osl-3.0.php). | ||
*/ | ||
|
||
namespace Magefan\Catalog\Plugin\Magento\Catalog\Block\Product; | ||
|
||
/** | ||
* Class ListProduct | ||
* @package Magefan\Catalog\Plugin\Magento\Catalog\Block\Product | ||
*/ | ||
class ListProduct | ||
{ | ||
/** | ||
* Max. dentities count | ||
*/ | ||
const MAX_COUNT = 400; | ||
|
||
/** | ||
* Slice identities. | ||
* @param \Magento\Catalog\Block\Product\ListProduct $subject | ||
* @param array $identities | ||
*/ | ||
public function afterGetIdentities( | ||
\Magento\Catalog\Block\Product\ListProduct $subject, | ||
$identities | ||
) { | ||
if (count($identities) > self::MAX_COUNT) { | ||
$identities = array_slice($identities, 0, self::MAX_COUNT); | ||
$category = $subject->getLayer()->getCurrentCategory(); | ||
if ($category) { | ||
$identities[] = \Magento\Catalog\Model\Product::CACHE_PRODUCT_CATEGORY_TAG . '_' . $category->getId(); | ||
} | ||
} | ||
|
||
return $identities; | ||
} | ||
} |
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