Skip to content

Commit 3ed9a1c

Browse files
author
Stanislav Idolov
committed
MAGETWO-66195: SQL Error during price reindexation process for custom profile
1 parent 74350c7 commit 3ed9a1c

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/CompositeProductRowSizeEstimator.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
*/
1616
class CompositeProductRowSizeEstimator implements IndexTableRowSizeEstimatorInterface
1717
{
18+
/**
19+
* Calculated memory size for one record in catalog_product_index_price table
20+
*/
21+
const MEMORY_SIZE_FOR_ONE_ROW = 200;
22+
1823
/**
1924
* @var DefaultPrice
2025
*/
@@ -76,8 +81,8 @@ public function estimateRowSize()
7681
* $maxRelatedProductCount - maximum number of related products
7782
* $websitesCount - active websites
7883
* $customerGroupCount - active customer groups
79-
* 200 - calculated memory size for one record in catalog_product_index_price table
84+
* MEMORY_SIZE_FOR_ONE_ROW - calculated memory size for one record in catalog_product_index_price table
8085
*/
81-
return ceil($maxRelatedProductCount * $websitesCount * $customerGroupCount * 200);
86+
return ceil($maxRelatedProductCount * $websitesCount * $customerGroupCount * self::MEMORY_SIZE_FOR_ONE_ROW);
8287
}
8388
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Price/IndexTableRowSizeEstimator.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
*/
1313
class IndexTableRowSizeEstimator implements \Magento\Framework\Indexer\IndexTableRowSizeEstimatorInterface
1414
{
15+
/**
16+
* Calculated memory size for one record in catalog_product_index_price table
17+
*/
18+
const MEMORY_SIZE_FOR_ONE_ROW = 120;
19+
1520
/**
1621
* @var \Magento\Store\Api\WebsiteManagementInterface
1722
*/
@@ -51,8 +56,8 @@ public function estimateRowSize()
5156
*
5257
* $websitesCount - active websites
5358
* $customerGroupCount - active customer groups
54-
* 120 - calculated memory size for one record in catalog_product_index_price table
59+
* MEMORY_SIZE_FOR_ONE_ROW - calculated memory size for one record in catalog_product_index_price table
5560
*/
56-
return ceil($websitesCount * $customerGroupCount * 120);
61+
return ceil($websitesCount * $customerGroupCount * self::MEMORY_SIZE_FOR_ONE_ROW);
5762
}
5863
}

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/TemporaryTableStrategy.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
class TemporaryTableStrategy implements \Magento\Framework\Indexer\Table\StrategyInterface
1313
{
14+
/**
15+
* Suffix for new temporary table
16+
*/
1417
const TEMP_SUFFIX = '_temp';
1518

1619
/**
@@ -31,7 +34,7 @@ class TemporaryTableStrategy implements \Magento\Framework\Indexer\Table\Strateg
3134
* @param \Magento\Framework\App\ResourceConnection $resource
3235
*/
3336
public function __construct(
34-
\Magento\Framework\Indexer\Table\Strategy $strategy,
37+
\Magento\Framework\Indexer\Table\StrategyInterface $strategy,
3538
\Magento\Framework\App\ResourceConnection $resource
3639
) {
3740
$this->strategy = $strategy;

app/code/Magento/Catalog/etc/di.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,11 @@
947947
<argument name="indexerFrontendResource" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\FrontendResource</argument>
948948
</arguments>
949949
</type>
950-
<type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy" shared="false" />
950+
<type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy" shared="false">
951+
<arguments>
952+
<argument name="strategy" xsi:type="object">Magento\Framework\Indexer\Table\Strategy</argument>
953+
</arguments>
954+
</type>
951955
<type name="Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\DefaultPrice">
952956
<arguments>
953957
<argument name="tableStrategy" xsi:type="object">Magento\Catalog\Model\ResourceModel\Product\Indexer\TemporaryTableStrategy</argument>

0 commit comments

Comments
 (0)