Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProductIdentitiesExtender.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
13 
18 {
22  private $configurableType;
23 
27  private $productRepository;
28 
33  public function __construct(Configurable $configurableType, ProductRepositoryInterface $productRepository)
34  {
35  $this->configurableType = $configurableType;
36  $this->productRepository = $productRepository;
37  }
38 
47  public function afterGetIdentities(Product $subject, array $identities): array
48  {
49  foreach ($this->configurableType->getParentIdsByChild($subject->getId()) as $parentId) {
50  $parentProduct = $this->productRepository->getById($parentId);
51  $identities = array_merge($identities, $parentProduct->getIdentities());
52  }
53 
54  return array_unique($identities);
55  }
56 }
__construct(Configurable $configurableType, ProductRepositoryInterface $productRepository)