/**
  * @magentoDbIsolation enabled
  * @magentoAppIsolation enabled
  * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
  * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testReindexFull()
 {
     $this->prepareProducts();
     $this->indexerBuilder->reindexFull();
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, 1));
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, $this->productSecond->getId()));
     $this->assertFalse($this->resourceRule->getRulePrice(new \DateTime(), 1, 1, $this->productThird->getId()));
 }
예제 #2
0
 /**
  * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  */
 public function testReindexAfterRuleCreation()
 {
     $this->product->load(1)->setData('test_attribute', 'test_attribute_value')->save();
     $this->assertFalse($this->resourceRule->getRulePrice(new \DateTime(), 1, 1, 1));
     $this->saveRule();
     // apply all rules
     $this->indexBuilder->reindexFull();
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, 1));
 }
예제 #3
0
 /**
  * @magentoDbIsolation enabled
  * @dataProvider dataProvider
  */
 public function testPriceForSmallBatch($batchCount, $price, $expectedPrice)
 {
     $productIds = $this->prepareProducts($price);
     /**
      * @var IndexBuilder $indexerBuilder
      */
     $indexerBuilder = Bootstrap::getObjectManager()->create('Magento\\CatalogRule\\Model\\Indexer\\IndexBuilder', ['batchCount' => $batchCount]);
     $indexerBuilder->reindexFull();
     foreach ([0, 1] as $customerGroupId) {
         foreach ($productIds as $productId) {
             $this->assertEquals($expectedPrice, $this->resourceRule->getRulePrice(new \DateTime(), 1, $customerGroupId, $productId));
         }
     }
 }
 public function testGetAmountNoBaseAmount()
 {
     $this->catalogRuleResourceMock->expects($this->once())->method('getRulePrice')->will($this->returnValue(false));
     $result = $this->object->getValue();
     $this->assertFalse($result);
 }
예제 #5
0
 /**
  * Create catalog rule relations for imported products
  *
  * @param EventObserver $observer
  * @return void
  */
 public function createCatalogRulesRelations(EventObserver $observer)
 {
     $adapter = $observer->getEvent()->getAdapter();
     $affectedEntityIds = $adapter->getAffectedEntityIds();
     if (empty($affectedEntityIds)) {
         return;
     }
     $rules = $this->_ruleCollectionFactory->create()->addFieldToFilter('is_active', 1);
     foreach ($rules as $rule) {
         $rule->setProductsFilter($affectedEntityIds);
         $this->_resourceRule->updateRuleProductData($rule);
     }
 }
예제 #6
0
 /**
  * @magentoDataFixture Magento/CatalogRule/_files/attribute.php
  * @magentoDataFixture Magento/CatalogRule/_files/rule_by_attribute.php
  * @magentoDataFixture Magento/Catalog/_files/product_simple.php
  * @magentoAppArea adminhtml
  */
 public function testReindexAfterSuitableProductSaving()
 {
     $this->product->load(1)->setData('test_attribute', 'test_attribute_value')->save();
     $this->assertEquals(9.800000000000001, $this->resourceRule->getRulePrice(new \DateTime(), 1, 1, 1));
 }