Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RemoveProducts.php
Go to the documentation of this file.
1 <?php
8 
10 use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
13 
18 {
24  private $collectionFactory;
25 
31  public function __construct(CollectionFactory $collectionFactory)
32  {
33  $this->collectionFactory = $collectionFactory;
34  }
35 
46  public function afterDelete(
48  bool $result,
50  ) {
52  $productCollection = $this->collectionFactory->create();
53  $productCollection->addFieldToFilter('attribute_set_id', ['eq' => $attributeSet->getId()]);
54  $productCollection->delete();
55 
56  return $result;
57  }
58 }