Product.php 861 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Bundle\Model\Plugin;
  7. use Magento\Bundle\Model\Product\Type;
  8. use Magento\Catalog\Model\Product as CatalogProduct;
  9. class Product
  10. {
  11. /**
  12. * @var Type
  13. */
  14. private $type;
  15. /**
  16. * @param Type $type
  17. */
  18. public function __construct(Type $type)
  19. {
  20. $this->type = $type;
  21. }
  22. /**
  23. * @param CatalogProduct $product
  24. * @param array $identities
  25. * @return string[]
  26. */
  27. public function afterGetIdentities(
  28. CatalogProduct $product,
  29. array $identities
  30. ) {
  31. foreach ($this->type->getParentIdsByChild($product->getEntityId()) as $parentId) {
  32. $identities[] = CatalogProduct::CACHE_TAG . '_' . $parentId;
  33. }
  34. return $identities;
  35. }
  36. }