-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix double sorting for some attribute, fix configurable products issue
- Loading branch information
Showing
4 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace GhoSter\OutOfStockAtLast\Model\Indexer\Stock; | ||
|
||
use Magento\ConfigurableProduct\Model\ResourceModel\Indexer\Stock\Configurable as DefaultIndexer; | ||
use Magento\Framework\DB\Select; | ||
|
||
class Configurable extends DefaultIndexer | ||
{ | ||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function _getStockStatusSelect($entityIds = null, $usePrimaryTable = false) | ||
{ | ||
$select = parent::_getStockStatusSelect($entityIds, $usePrimaryTable); | ||
$this->_autoCalculate($select); | ||
|
||
return $select; | ||
} | ||
|
||
/** | ||
* Calculate depends on simple products | ||
* | ||
* @param Select $select | ||
* @throws \Zend_Db_Select_Exception | ||
*/ | ||
private function _autoCalculate($select) | ||
{ | ||
$columns = $select->getPart(Select::COLUMNS); | ||
foreach ($columns as &$column) { | ||
if (isset($column[2]) && $column[2] == 'qty') { | ||
$column[1] = new \Zend_Db_Expr('SUM(IF(i.stock_status > 0, i.qty, 0))'); | ||
} | ||
} | ||
$select->setPart(Select::COLUMNS, $columns); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/product_types.xsd"> | ||
<type name="configurable" label="Configurable Product" modelInstance="Magento\ConfigurableProduct\Model\Product\Type\Configurable"> | ||
<stockIndexerModel instance="GhoSter\OutOfStockAtLast\Model\Indexer\Stock\Configurable" /> | ||
</type> | ||
</config> |