-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' into patch-1
- Loading branch information
Showing
153 changed files
with
7,453 additions
and
1,000 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
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
74 changes: 74 additions & 0 deletions
74
app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilter.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,74 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogInventory\Model\ResourceModel; | ||
|
||
use Magento\CatalogInventory\Api\Data\StockStatusInterface; | ||
use Magento\CatalogInventory\Api\StockConfigurationInterface; | ||
use Magento\CatalogInventory\Model\Stock; | ||
use Magento\Framework\App\ResourceConnection; | ||
use Magento\Framework\DB\Select; | ||
|
||
/** | ||
* Generic in-stock status filter | ||
*/ | ||
class StockStatusFilter implements StockStatusFilterInterface | ||
{ | ||
private const TABLE_NAME = 'cataloginventory_stock_status'; | ||
/** | ||
* @var ResourceConnection | ||
*/ | ||
private $resource; | ||
|
||
/** | ||
* @var StockConfigurationInterface | ||
*/ | ||
private $stockConfiguration; | ||
|
||
/** | ||
* @param ResourceConnection $resource | ||
* @param StockConfigurationInterface $stockConfiguration | ||
*/ | ||
public function __construct( | ||
ResourceConnection $resource, | ||
StockConfigurationInterface $stockConfiguration | ||
) { | ||
$this->resource = $resource; | ||
$this->stockConfiguration = $stockConfiguration; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function execute( | ||
Select $select, | ||
string $productTableAlias, | ||
string $stockStatusTableAlias = self::TABLE_ALIAS, | ||
?int $websiteId = null | ||
): Select { | ||
$stockStatusTable = $this->resource->getTableName(self::TABLE_NAME); | ||
$joinCondition = [ | ||
"{$stockStatusTableAlias}.product_id = {$productTableAlias}.entity_id", | ||
$select->getConnection()->quoteInto( | ||
"{$stockStatusTableAlias}.website_id = ?", | ||
$this->stockConfiguration->getDefaultScopeId() | ||
), | ||
$select->getConnection()->quoteInto( | ||
"{$stockStatusTableAlias}.stock_id = ?", | ||
Stock::DEFAULT_STOCK_ID | ||
) | ||
]; | ||
$select->join( | ||
[$stockStatusTableAlias => $stockStatusTable], | ||
implode(' AND ', $joinCondition), | ||
[] | ||
); | ||
$select->where("{$stockStatusTableAlias}.stock_status = ?", StockStatusInterface::STATUS_IN_STOCK); | ||
|
||
return $select; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
app/code/Magento/CatalogInventory/Model/ResourceModel/StockStatusFilterInterface.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,34 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogInventory\Model\ResourceModel; | ||
|
||
use Magento\Framework\DB\Select; | ||
|
||
/** | ||
* In stock status filter interface. | ||
*/ | ||
interface StockStatusFilterInterface | ||
{ | ||
public const TABLE_ALIAS = 'stock_status'; | ||
|
||
/** | ||
* Add in-stock status constraint to the select. | ||
* | ||
* @param Select $select | ||
* @param string $productTableAliasAlias | ||
* @param string $stockStatusTableAlias | ||
* @param int|null $websiteId | ||
* @return Select | ||
*/ | ||
public function execute( | ||
Select $select, | ||
string $productTableAliasAlias, | ||
string $stockStatusTableAlias = self::TABLE_ALIAS, | ||
?int $websiteId = null | ||
): 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
Oops, something went wrong.