Skip to content

Commit

Permalink
Merge pull request magento#113 from magento-troll/Troll_S31
Browse files Browse the repository at this point in the history
[Troll] Sprint 31
  • Loading branch information
vpelipenko committed Mar 3, 2015
2 parents 5e0aeea + a2028b1 commit daced02
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 134 deletions.
15 changes: 10 additions & 5 deletions app/code/Magento/Catalog/Model/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -836,12 +836,12 @@ public function eavReindexCallback()
public function reindex()
{
if ($this->_catalogProduct->isDataForProductCategoryIndexerWasChanged($this) || $this->isDeleted()) {
$this->_productFlatIndexerProcessor->reindexRow($this->getEntityId());
$categoryIndexer = $this->indexerRegistry->get(Indexer\Product\Category::INDEXER_ID);
if (!$categoryIndexer->isScheduled()) {
$categoryIndexer->reindexRow($this->getId());
$productCategoryIndexer = $this->indexerRegistry->get(Indexer\Product\Category::INDEXER_ID);
if (!$productCategoryIndexer->isScheduled()) {
$productCategoryIndexer->reindexRow($this->getId());
}
}
$this->_productFlatIndexerProcessor->reindexRow($this->getEntityId());
}

/**
Expand Down Expand Up @@ -2013,7 +2013,12 @@ public function getIdentities()
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
}
}
return $identities;
if ($this->getOrigData('status') > $this->getData('status')) {
foreach ($this->getData('category_ids') as $categoryId) {
$identities[] = self::CACHE_PRODUCT_CATEGORY_TAG . '_' . $categoryId;
}
}
return array_unique($identities);
}

/**
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
<item name="entity_id" xsi:type="string">entity_id</item>
<item name="store_id" xsi:type="string">store_id</item>
<item name="visibility" xsi:type="string">visibility</item>
<item name="status" xsi:type="string">status</item>
</item>
</argument>
<argument name="productRepository" xsi:type="object">Magento\Catalog\Api\ProductRepositoryInterface\Proxy</argument>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,77 @@
-->
<config>
<profile>
<websites>1</websites> <!-- Number of websites to generate -->
<store_groups>1</store_groups> <!--Number of stores-->
<store_views>1</store_views> <!-- Number of store views -->
<simple_products>30</simple_products> <!-- Simple products count -->
<configurable_products>10</configurable_products> <!--Configurable products count (each configurable has 3 simple products as options, that are not displayed individually in catalog) -->
<categories>5</categories> <!-- Number of categories to generate -->
<categories_nesting_level>3</categories_nesting_level> <!-- Nesting level for categories -->
<catalog_price_rules>1</catalog_price_rules> <!-- Number os catalog price rules -->
<cart_price_rules>1</cart_price_rules> <!-- Number of shopping cart price rules -->
<cart_price_rules_floor>1</cart_price_rules_floor> <!-- The price rule condition: minimum products amount in shopping cart for price rule to be applied -->
<customers>5</customers> <!-- Number of customers to generate -->
<websites>1</websites>
<!-- Number of websites to generate -->
<store_groups>1</store_groups>
<!--Number of stores-->
<store_views>1</store_views>
<!-- Number of store views -->
<simple_products>800</simple_products>
<!-- Simple products count -->
<configurable_products>50</configurable_products>
<!--Configurable products count (each configurable has 3 simple products as options, that are not displayed individually in catalog) -->
<categories>30</categories>
<!-- Number of categories to generate -->
<categories_nesting_level>3</categories_nesting_level>
<!-- Nesting level for categories -->
<catalog_price_rules>10</catalog_price_rules>
<!-- Number os catalog price rules -->
<cart_price_rules>10</cart_price_rules>
<!-- Number of shopping cart price rules -->
<cart_price_rules_floor>2</cart_price_rules_floor>
<!-- The price rule condition: minimum products amount in shopping cart for price rule to be applied -->
<customers>20</customers>
<!-- Number of customers to generate -->
<configs> <!-- Config variables and values for change -->
<config>
<path>admin/security/use_form_key</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>0</value>
</config>
<config>
<path>carriers/flatrate/active</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>1</value>
</config>
<config>
<path>system/full_page_cache/ttl</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>7200</value>
</config>
<config>
<path>system/full_page_cache/caching_application</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>2</value>
</config>
<config>
<path>checkout/cart/redirect_to_cart</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>0</value>
</config>
<config>
<path>system/full_page_cache/varnish/access_lis</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>localhost</value>
</config>
<config>
<path>system/full_page_cache/varnish/backend_host</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>localhost</value>
</config>
<config>
<path>system/full_page_cache/varnish/backend_port</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>8080</value>
</config>
</configs>
</profile>
</config>
</config>
38 changes: 29 additions & 9 deletions dev/tests/unit/testsuite/Magento/Catalog/Model/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,20 @@ public function testIndexerAfterDeleteCommitProduct()
public function testReindex($productChanged, $isScheduled, $productFlatCount, $categoryIndexerCount)
{
$this->model->setData('entity_id', 1);
$this->_catalogProduct->expects($this->once())->method('isDataForProductCategoryIndexerWasChanged')->willReturn($productChanged);
$this->_catalogProduct->expects($this->once())
->method('isDataForProductCategoryIndexerWasChanged')
->willReturn($productChanged);
if ($productChanged) {
$this->indexerRegistryMock->expects($this->exactly($productFlatCount))
->method('get')
->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)
->will($this->returnValue($this->categoryIndexerMock));
$this->categoryIndexerMock->expects($this->any())
->method('isScheduled')
->will($this->returnValue($isScheduled));
$this->categoryIndexerMock->expects($this->exactly($categoryIndexerCount))->method('reindexRow');
}
$this->productFlatProcessor->expects($this->exactly($productFlatCount))->method('reindexRow');
$this->indexerRegistryMock->expects($this->exactly($productFlatCount))
->method('get')
->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)
->will($this->returnValue($this->categoryIndexerMock));
$this->categoryIndexerMock->expects($this->any())->method('isScheduled')->will($this->returnValue($isScheduled));
$this->categoryIndexerMock->expects($this->exactly($categoryIndexerCount))->method('reindexRow');

$this->model->reindex();
}

Expand All @@ -400,7 +405,7 @@ public function getProductReindexProvider()
return array(
'set 1' => [true, false, 1, 1],
'set 2' => [true, true, 1, 0],
'set 3' => [false, false, 0, 0]
'set 3' => [false, false, 1, 0]
);
}

Expand Down Expand Up @@ -465,6 +470,21 @@ public function getIdentitiesProvider()
'affected_category_ids' => [1],
'is_changed_categories' => true
]
],
[
[0 => 'catalog_product_1', 1 => 'catalog_category_product_1'],
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2],
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
],
[
[0 => 'catalog_product_1'],
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2],
],
[
[0 => 'catalog_product_1'],
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2],
['id' => 1, 'name' => 'value', 'category_ids' => [], 'status' => 1],
]
];
}
Expand Down
57 changes: 57 additions & 0 deletions dev/tools/performance-toolkit/fixtures/configs_apply.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

/**
* Class ConfigsApplyFixture
*/
class ConfigsApplyFixture extends \Magento\ToolkitFramework\Fixture
{
/**
* @var int
*/
protected $priority = 150;

/**
* {@inheritdoc}
*/
public function execute()
{
$configs = \Magento\ToolkitFramework\Config::getInstance()->getValue('configs', array());
$this->application->resetObjectManager();

foreach ($configs['config'] as $config) {
/**
* @var \Magento\Framework\App\Config\Value $configData
*/
$configData = $this->application->getObjectManager()->create('Magento\Framework\App\Config\Value');
$configData->setPath($config['path'])
->setScope($config['scope'])
->setScopeId($config['scopeId'])
->setValue($config['value'])
->save();
}
$this->application->getObjectManager()->get('Magento\Framework\App\CacheInterface')
->clean([\Magento\Framework\App\Config::CACHE_TAG]);
}

/**
* {@inheritdoc}
*/
public function getActionTitle()
{
return 'Config Changes';
}

/**
* {@inheritdoc}
*/
public function introduceParamLabels()
{
return [];
}
}

return new ConfigsApplyFixture($this);
54 changes: 0 additions & 54 deletions dev/tools/performance-toolkit/fixtures/disable_form_key_usage.php

This file was deleted.

This file was deleted.

14 changes: 14 additions & 0 deletions dev/tools/performance-toolkit/profiles/ce/extra_large.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,19 @@
<cart_price_rules>100</cart_price_rules> <!-- Number of shopping cart price rules -->
<cart_price_rules_floor>5</cart_price_rules_floor> <!-- The price rule condition: minimum products amount in shopping cart for price rule to be applied -->
<customers>5000</customers> <!-- Number of customers to generate -->
<configs> <!-- Config variables and values for change -->
<config>
<path>admin/security/use_form_key</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>0</value>
</config>
<config>
<path>carriers/flatrate/active</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>1</value>
</config>
</configs>
</profile>
</config>
14 changes: 14 additions & 0 deletions dev/tools/performance-toolkit/profiles/ce/large.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,19 @@
<cart_price_rules>50</cart_price_rules> <!-- Number of shopping cart price rules -->
<cart_price_rules_floor>2</cart_price_rules_floor> <!-- The price rule condition: minimum products amount in shopping cart for price rule to be applied -->
<customers>2000</customers> <!-- Number of customers to generate -->
<configs> <!-- Config variables and values for change -->
<config>
<path>admin/security/use_form_key</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>0</value>
</config>
<config>
<path>carriers/flatrate/active</path>
<scope>default</scope>
<scopeId>0</scopeId>
<value>1</value>
</config>
</configs>
</profile>
</config>
Loading

0 comments on commit daced02

Please sign in to comment.