/**
  * Saving product inventory data. Product qty calculated dynamically.
  *
  * @param EventObserver $observer
  * @return $this
  */
 public function execute(EventObserver $observer)
 {
     $product = $observer->getEvent()->getProduct();
     if ($product->getStockData() === null) {
         if ($product->getIsChangedWebsites() || $product->dataHasChangedFor('status')) {
             $this->stockIndex->rebuild($product->getId(), $product->getStore()->getWebsiteId());
         }
         return $this;
     }
     $this->saveStockItemData($product);
     return $this;
 }
Пример #2
0
 /**
  * Catalog Product website update
  *
  * @param EventObserver $observer
  * @return void
  */
 public function catalogProductWebsiteUpdate(EventObserver $observer)
 {
     $websiteIds = $observer->getEvent()->getWebsiteIds();
     $productIds = $observer->getEvent()->getProductIds();
     foreach ($websiteIds as $websiteId) {
         foreach ($productIds as $productId) {
             $this->stockIndex->rebuild($productId, $websiteId);
         }
     }
 }