diff --git a/Observer/Product/AbstractChangedProductObserver.php b/Observer/Product/AbstractChangedProductObserver.php index 094dc960..b809f44a 100644 --- a/Observer/Product/AbstractChangedProductObserver.php +++ b/Observer/Product/AbstractChangedProductObserver.php @@ -12,6 +12,7 @@ use Doofinder\Feed\Model\ChangedItemFactory; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\Product\Attribute\Source\Status; +use Magento\Catalog\Model\Product\Visibility; use \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable; use Magento\Framework\Event\Observer; use Magento\Framework\Event\ObserverInterface; @@ -44,6 +45,11 @@ abstract class AbstractChangedProductObserver implements ObserverInterface */ private $configurableProductType; + /** + * @var [] + */ + private $visibilityAllowed; + /** * AbstractChangedProductObserver constructor. * @@ -65,6 +71,7 @@ public function __construct( $this->changedItemRepository = $changedItemRepository; $this->logger = $logger; $this->configurableProductType = $configurableProductType; + $this->visibilityAllowed = [Visibility::VISIBILITY_IN_SEARCH, visibility::VISIBILITY_BOTH]; } /** @@ -79,6 +86,8 @@ public function execute(Observer $observer) if ($product->getStatus() == Status::STATUS_DISABLED) { $this->setOperationType(ChangedItemInterface::OPERATION_TYPE_DELETE); + } elseif (!in_array($product->getVisibility(), $this->visibilityAllowed)){ + $this->setOperationType(ChangedItemInterface::OPERATION_TYPE_DELETE); } elseif ($product->getUpdatedAt() == $product->getCreatedAt() && $operationType == ChangedItemInterface::OPERATION_TYPE_UPDATE ) { diff --git a/composer.json b/composer.json index 2b1bd455..30dcbb4d 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "doofinder/doofinder-magento2", - "version": "1.0.0", + "version": "1.0.1", "description": "Doofinder module for Magento 2", "type": "magento2-module", "require": { diff --git a/etc/module.xml b/etc/module.xml index f22d9571..3b29e79c 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,6 +1,6 @@ - +