/** * Delete data specific for Downloadable product type * * @param \Magento\Catalog\Model\Product $product * @return void */ public function deleteTypeSpecificData(\Magento\Catalog\Model\Product $product) { if ($product->getOrigData('type_id') === \Magento\Downloadable\Model\Product\Type::TYPE_DOWNLOADABLE) { $downloadableData = $product->getDownloadableData(); $sampleItems = []; if (isset($downloadableData['sample'])) { foreach ($downloadableData['sample'] as $sample) { $sampleItems[] = $sample['sample_id']; } } if ($sampleItems) { $this->_sampleResFactory->create()->deleteItems($sampleItems); } $linkItems = []; if (isset($downloadableData['link'])) { foreach ($downloadableData['link'] as $link) { $linkItems[] = $link['link_id']; } } if ($linkItems) { $this->_linkResource->deleteItems($linkItems); } } }
/** * {@inheritdoc} */ protected function processDelete() { if ($this->deletedItems) { $this->sampleResourceFactory->create()->deleteItems($this->deletedItems); } }