Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CreateHandler.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
20  protected $linkRepository;
21 
26  {
27  $this->linkRepository = $linkRepository;
28  }
29 
36  public function execute($entity, $arguments = [])
37  {
39  if ($entity->getTypeId() != Type::TYPE_DOWNLOADABLE) {
40  return $entity;
41  }
42 
44  $links = $entity->getExtensionAttributes()->getDownloadableProductLinks() ?: [];
45  foreach ($links as $link) {
46  $link->setId(null);
47  $this->linkRepository->save($entity->getSku(), $link, !(bool)$entity->getStoreId());
48  }
49 
50  return $entity;
51  }
52 }
$entity
Definition: element.phtml:22
$arguments