-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from DivanteLtd/develop
Update version to work with new Pimcore
- Loading branch information
Showing
5 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
Plugin/Model/ResourceModel/Attribute/InStockOptionSelectBuilder.php
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,59 @@ | ||
<?php | ||
/** | ||
* @package Divante\PimcoreIntegration | ||
* @author Bartosz Herba <[email protected]> | ||
* @copyright 2019 Divante Sp. z o.o. | ||
* @license See LICENSE_DIVANTE.txt for license details. | ||
*/ | ||
|
||
namespace Divante\PimcoreIntegration\Plugin\Model\ResourceModel\Attribute; | ||
|
||
use Magento\CatalogInventory\Model\ResourceModel\Stock\Status; | ||
use Magento\CatalogInventory\Model\Stock\Status as StockStatus; | ||
use Magento\ConfigurableProduct\Model\ResourceModel\Attribute\OptionSelectBuilderInterface; | ||
use Magento\Framework\DB\Select; | ||
|
||
/** | ||
* Class InStockOptionSelectBuilder | ||
*/ | ||
class InStockOptionSelectBuilder | ||
{ | ||
/** | ||
* CatalogInventory Stock Status Resource Model. | ||
* | ||
* @var Status | ||
*/ | ||
private $stockStatusResource; | ||
|
||
/** | ||
* @param Status $stockStatusResource | ||
*/ | ||
public function __construct(Status $stockStatusResource) | ||
{ | ||
$this->stockStatusResource = $stockStatusResource; | ||
} | ||
|
||
/** | ||
* Add stock status filter to select. | ||
* | ||
* @param OptionSelectBuilderInterface $subject | ||
* @param Select $select | ||
* | ||
* @return Select | ||
* | ||
* @SuppressWarnings(PHPMD.UnusedFormalParameter) | ||
*/ | ||
public function afterGetSelect(OptionSelectBuilderInterface $subject, Select $select) | ||
{ | ||
$select->joinInner( | ||
['stock' => $this->stockStatusResource->getMainTable()], | ||
'stock.product_id = entity.entity_id', | ||
[] | ||
)->where( | ||
'stock.stock_status IN (?)', | ||
[StockStatus::STATUS_IN_STOCK, StockStatus::STATUS_OUT_OF_STOCK] | ||
); | ||
|
||
return $select; | ||
} | ||
} |
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
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