Skip to content

Commit

Permalink
Merge pull request #2224 from magento-performance/MAGETWO-89277
Browse files Browse the repository at this point in the history
Bug: 
- MAGETWO-89277 [Forwardport] Product Price indexer stuck during reindexing
  • Loading branch information
duhon authored Mar 19, 2018
2 parents 3dda470 + 5bfc46b commit dea8b32
Showing 1 changed file with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@
namespace Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price;

use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
use Magento\Store\Api\StoreResolverInterface;
use Magento\Store\Model\Store;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
Expand Down Expand Up @@ -58,7 +55,7 @@ protected function reindex($entityIds = null)
if ($this->hasEntity() || !empty($entityIds)) {
$this->prepareFinalPriceDataForType($entityIds, $this->getTypeId());
$this->_applyCustomOption();
$this->_applyConfigurableOption();
$this->_applyConfigurableOption($entityIds);
$this->_movePriceDataToIndexTable($entityIds);
}
return $this;
Expand Down Expand Up @@ -110,10 +107,11 @@ protected function _prepareConfigurableOptionPriceTable()
* Calculate minimal and maximal prices for configurable product options
* and apply it to final price
*
* @param array|null $entityIds
* @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Indexer\Price\Configurable
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
protected function _applyConfigurableOption()
protected function _applyConfigurableOption($entityIds = null)
{
$metadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
$connection = $this->getConnection();
Expand All @@ -133,12 +131,12 @@ protected function _applyConfigurableOption()
['le' => $this->getTable('catalog_product_entity')],
'le.' . $linkField . ' = l.parent_id',
['parent_id' => 'entity_id']
)->join(
['i' => $this->_getDefaultFinalPriceTable()],
'le.entity_id = i.entity_id',
[]
);

if ($entityIds !== null) {
$subSelect->where('le.entity_id IN (?)', $entityIds);
}

$select = $connection->select();
$select
->from(['sub' => new \Zend_Db_Expr('(' . (string)$subSelect . ')')], '')
Expand Down Expand Up @@ -178,6 +176,7 @@ protected function _applyConfigurableOption()
' AND i.website_id = io.website_id',
[]
);
// adds price of custom option, that was applied in DefaultPrice::_applyCustomOption
$select->columns(
[
'min_price' => new \Zend_Db_Expr('i.min_price - i.orig_price + io.min_price'),
Expand Down

0 comments on commit dea8b32

Please sign in to comment.