Esempio n. 1
0
 /**
  * Apply catalog rules after product save
  *
  * @param Product $subject
  * @param Product $result
  * @return Product
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterSave(Product $subject, Product $result)
 {
     if (!$result->getIsMassupdate()) {
         $this->productRuleProcessor->reindexRow($result->getId());
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * @param ProductAction $object
  * @param ProductAction $result
  * @return ProductAction
  *
  * @SuppressWarnings(PHPMD.UnusedFormatParameter)
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterUpdateAttributes(ProductAction $object, ProductAction $result)
 {
     $data = $result->getAttributesData();
     if (!empty($data['price'])) {
         $this->productRuleProcessor->reindexList($result->getProductIds());
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * Apply catalog rules after product resource model save
  *
  * @param \Magento\Catalog\Model\ResourceModel\Product $subject
  * @param callable $proceed
  * @param \Magento\Framework\Model\AbstractModel $product
  * @return \Magento\Catalog\Model\ResourceModel\Product
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function aroundSave(\Magento\Catalog\Model\ResourceModel\Product $subject, callable $proceed, \Magento\Framework\Model\AbstractModel $product)
 {
     $productResource = $proceed($product);
     if (!$product->getIsMassupdate()) {
         $this->productRuleProcessor->reindexRow($product->getId());
     }
     return $productResource;
 }
Esempio n. 4
0
 public function testAfterUpdateAttributesWithPrice()
 {
     $productIds = [1, 2, 3];
     $subject = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Action')->disableOriginalConstructor()->setMethods([])->getMock();
     $result = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Action')->disableOriginalConstructor()->setMethods(['getAttributesData', 'getProductIds'])->getMock();
     $result->expects($this->once())->method('getAttributesData')->willReturn(['price' => 100]);
     $result->expects($this->once())->method('getProductIds')->willReturn($productIds);
     $this->productRuleProcessor->expects($this->once())->method('reindexList')->with($productIds);
     $this->action->afterUpdateAttributes($subject, $result);
 }
Esempio n. 5
0
 /**
  * @param \Magento\Catalog\Model\Category $subject
  * @param \Magento\Catalog\Model\Category $result
  * @return \Magento\Catalog\Model\Category
  *
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function afterDelete(\Magento\Catalog\Model\Category $subject, \Magento\Catalog\Model\Category $result)
 {
     $this->productRuleProcessor->markIndexerAsInvalid();
     return $result;
 }
Esempio n. 6
0
 public function testAfterDelete()
 {
     $this->productRuleProcessor->expects($this->once())->method('markIndexerAsInvalid');
     $this->assertEquals($this->subject, $this->plugin->afterDelete($this->subject, $this->subject));
 }
 /**
  * Apply catalog rules after product resource model save
  *
  * @param \Magento\Catalog\Model\Product $subject
  * @param callable $proceed
  * @return \Magento\Catalog\Model\Product
  */
 public function aroundReindex(\Magento\Catalog\Model\Product $subject, callable $proceed)
 {
     $proceed();
     $this->productRuleProcessor->reindexRow($subject->getId());
     return;
 }