Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- From
- // Check if the product belongs to category flash deal
- $allCategoryIds = $product->getCategoryIds();
- /** @var \Magento\Catalog\Model\ResourceModel\Category\Collection $categoryCollection */
- $categoryCollection = $this->_categoryCollection->create();
- $categoryCollection->addFieldToFilter('entity_id', ['in' => $allCategoryIds]);
- /** @var \Magento\Catalog\Model\Category[] $categories */
- $categories = $categoryCollection->getItems();
- foreach ($categories as $category) {
- $categoryIds = $category->getParentIds();
- $allCategoryIds = array_merge($allCategoryIds, $categoryIds);
- }
- $allCategoryIds = array_unique($allCategoryIds);
- if (in_array($value, $allCategoryIds)) {
- $canShow = true;
- }
- To
- // Check if the product belongs to category flash deal
- $categories = $product->getCategoryCollection();
- $allCategoryIds = [];
- foreach ($categories as $category) {
- $allCategoryIds = array_merge($allCategoryIds, explode('/', $category->getPath()));
- }
- if (in_array($value, $allCategoryIds)) {
- $canShow = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement