-
Notifications
You must be signed in to change notification settings - Fork 248
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 #70 from gabrieldagama/php8-2.4-sync
Php8 2.4 sync
- Loading branch information
Showing
93 changed files
with
1,089 additions
and
310 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
85 changes: 85 additions & 0 deletions
85
...minUi/Test/Mftf/Test/AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest.xml
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,85 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> | ||
<test name="AdminCreateOrderWithMultipleAddressCustomerWithSimpleProductTest"> | ||
<annotations> | ||
<stories value="Simple Product Single Stock."/> | ||
<title value="Admin Create Order With Multiple Addresses Customer"/> | ||
<description value="Verify admin able to create order for customer with multiple addresses on default stock."/> | ||
<testCaseId value="MC-40634"/> | ||
<useCaseId value="MC-40541"/> | ||
<severity value="MAJOR"/> | ||
<group value="msi"/> | ||
<group value="single_mode"/> | ||
</annotations> | ||
|
||
<before> | ||
<!--Create test data.--> | ||
<createData entity="SimpleProduct2" stepKey="product"/> | ||
<createData entity="Simple_US_Customer_With_Different_Billing_Shipping_Addresses" stepKey="customer"/> | ||
<actionGroup ref="AdminLoginActionGroup" stepKey="loginToAdminArea"/> | ||
<!--Assign Default Stock to Default Website.--> | ||
<actionGroup ref="AssignWebsiteToStockActionGroup" stepKey="assignMainWebsiteToDefaultStock"> | ||
<argument name="stockName" value="{{_defaultStock.name}}"/> | ||
<argument name="websiteName" value="{{_defaultWebsite.name}}"/> | ||
</actionGroup> | ||
<magentoCron stepKey="runCronIndex" groups="index"/> | ||
</before> | ||
<after> | ||
<!--Delete test data.--> | ||
<deleteData createDataKey="customer" stepKey="deleteCustomer"/> | ||
<deleteData createDataKey="product" stepKey="deleteProduct"/> | ||
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdminArea"/> | ||
</after> | ||
|
||
<!--Create order with simple product quantity.--> | ||
<actionGroup ref="NavigateToNewOrderPageExistingCustomerActionGroup" stepKey="createNewOrderForCustomer"> | ||
<argument name="customer" value="$customer$"/> | ||
</actionGroup> | ||
<actionGroup ref="AddSimpleProductToOrderActionGroup" stepKey="addProductToOrder"> | ||
<argument name="product" value="$product$"/> | ||
<argument name="productQty" value="{{defaultProductQty.value}}"/> | ||
</actionGroup> | ||
<!--Change customer billing address.--> | ||
<actionGroup ref="FillOrderCustomerInformationActionGroup" stepKey="changeBillingAddress"> | ||
<argument name="customer" value="$customer$"/> | ||
<argument name="address" value="US_Address_TX"/> | ||
</actionGroup> | ||
<!--Verify shipping address didn't change.--> | ||
<actionGroup ref="AssertAdminCreateOrderFormShippingAddressActionGroup" stepKey="verifyShippingAddress"> | ||
<argument name="prefix" value=""/> | ||
<argument name="firstname" value="$customer.firstname$"/> | ||
<argument name="middleName" value=""/> | ||
<argument name="lastname" value="$customer.lastname$"/> | ||
<argument name="suffix" value=""/> | ||
<argument name="company" value="{{US_Address_NY_Default_Shipping.company}}"/> | ||
<argument name="streetLine1" value="{{US_Address_NY_Default_Shipping.street[0]}}"/> | ||
<argument name="streetLine2" value="{{US_Address_NY_Default_Shipping.street[1]}}"/> | ||
<argument name="city" value="{{US_Address_NY_Default_Shipping.city}}"/> | ||
<argument name="country_id" value="{{US_Address_NY_Default_Shipping.country_id}}"/> | ||
<argument name="state" value="{{US_Address_NY_Default_Shipping.state}}"/> | ||
<argument name="postcode" value="{{US_Address_NY_Default_Shipping.postcode}}"/> | ||
<argument name="telephone" value="{{US_Address_NY_Default_Shipping.telephone}}"/> | ||
<argument name="fax" value=""/> | ||
<argument name="vatNumber" value=""/> | ||
</actionGroup> | ||
<!--Place order.--> | ||
<actionGroup ref="OrderSelectFlatRateShippingActionGroup" stepKey="selectFlatRateShipping"/> | ||
<actionGroup ref="SelectCheckMoneyPaymentMethodActionGroup" stepKey="selectCheckMoneyPayment"/> | ||
<actionGroup ref="AdminSubmitOrderActionGroup" stepKey="submitOrder"/> | ||
<actionGroup ref="VerifyCreatedOrderInformationActionGroup" stepKey="verifyCreatedOrderInformation"/> | ||
<!--Verify addresses are different.--> | ||
<actionGroup ref="AssertOrderAddressInformationActionGroup" stepKey="verifyAddressInformation"> | ||
<argument name="customer" value="$customer$"/> | ||
<argument name="shippingAddress" value="US_Address_NY_Default_Shipping"/> | ||
<argument name="billingAddress" value="US_Address_TX"/> | ||
<argument name="customerGroup" value=""/> | ||
</actionGroup> | ||
</test> | ||
</tests> |
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
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
59 changes: 59 additions & 0 deletions
59
InventoryCatalog/Model/ResourceModel/AddSortByStockQtyToCollection.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 | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryCatalog\Model\ResourceModel; | ||
|
||
use Magento\Catalog\Model\ResourceModel\Product\Collection; | ||
use Magento\InventoryIndexer\Indexer\IndexStructure; | ||
use Magento\InventoryIndexer\Model\StockIndexTableNameResolverInterface; | ||
|
||
/** | ||
* Add sort by stock quantity to product collection | ||
*/ | ||
class AddSortByStockQtyToCollection | ||
{ | ||
private const SORT_TABLE_ALIAS = 'stock_qty_sort'; | ||
|
||
/** | ||
* @var StockIndexTableNameResolverInterface | ||
*/ | ||
private $stockIndexTableProvider; | ||
|
||
/** | ||
* @param StockIndexTableNameResolverInterface $stockIndexTableProvider | ||
*/ | ||
public function __construct( | ||
StockIndexTableNameResolverInterface $stockIndexTableProvider | ||
) { | ||
$this->stockIndexTableProvider = $stockIndexTableProvider; | ||
} | ||
|
||
/** | ||
* Add sort by stock quantity to product collection | ||
* | ||
* @param Collection $collection | ||
* @param string $direction | ||
* @param int $stockId | ||
*/ | ||
public function execute( | ||
Collection $collection, | ||
string $direction, | ||
int $stockId | ||
): void { | ||
$stockIndexTable = $this->stockIndexTableProvider->execute($stockId); | ||
$stockIndexTableAlias = self::SORT_TABLE_ALIAS; | ||
$productTableAlias = Collection::MAIN_TABLE_ALIAS; | ||
$qtyFieldName = IndexStructure::QUANTITY; | ||
$collection->getSelect() | ||
->joinLeft( | ||
[$stockIndexTableAlias => $stockIndexTable], | ||
"{$stockIndexTableAlias}.sku = {$productTableAlias}.sku", | ||
[] | ||
) | ||
->order("{$stockIndexTableAlias}.{$qtyFieldName} {$direction}"); | ||
} | ||
} |
92 changes: 92 additions & 0 deletions
92
InventoryCatalog/Plugin/CatalogInventory/Model/Source/StockPlugin.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,92 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\InventoryCatalog\Plugin\CatalogInventory\Model\Source; | ||
|
||
use Magento\Catalog\Model\ResourceModel\Product\Collection; | ||
use Magento\CatalogInventory\Model\Source\Stock; | ||
use Magento\InventoryCatalog\Model\ResourceModel\AddSortByStockQtyToCollection; | ||
use Magento\InventoryCatalog\Model\ResourceModel\StockStatusFilter; | ||
use Magento\InventoryCatalogApi\Api\DefaultStockProviderInterface; | ||
use Magento\InventorySalesApi\Api\Data\SalesChannelInterface; | ||
use Magento\InventorySalesApi\Api\StockResolverInterface; | ||
use Magento\Store\Model\Store; | ||
use Magento\Store\Model\StoreManagerInterface; | ||
|
||
/** | ||
* Modify "sort by low/high stock" to support non-default stocks | ||
*/ | ||
class StockPlugin | ||
{ | ||
/** | ||
* @var StoreManagerInterface | ||
*/ | ||
private $storeManager; | ||
|
||
/** | ||
* @var StockResolverInterface | ||
*/ | ||
private $stockResolver; | ||
|
||
/** | ||
* @var DefaultStockProviderInterface | ||
*/ | ||
private $defaultStockProvider; | ||
|
||
/** | ||
* @var AddSortByStockQtyToCollection | ||
*/ | ||
private $addSortByStockQtyToCollection; | ||
|
||
/** | ||
* @param StoreManagerInterface $storeManager | ||
* @param StockResolverInterface $stockResolver | ||
* @param DefaultStockProviderInterface $defaultStockProvider | ||
* @param StockStatusFilter $stockStatusFilter | ||
* @param AddSortByStockQtyToCollection $addSortByStockQtyToCollection | ||
*/ | ||
public function __construct( | ||
StoreManagerInterface $storeManager, | ||
StockResolverInterface $stockResolver, | ||
DefaultStockProviderInterface $defaultStockProvider, | ||
AddSortByStockQtyToCollection $addSortByStockQtyToCollection | ||
) { | ||
$this->storeManager = $storeManager; | ||
$this->stockResolver = $stockResolver; | ||
$this->defaultStockProvider = $defaultStockProvider; | ||
$this->addSortByStockQtyToCollection = $addSortByStockQtyToCollection; | ||
} | ||
|
||
/** | ||
* Modify "sort by low/high stock" to support non-default stocks. | ||
* | ||
* @param Stock $subject | ||
* @param callable $proceed | ||
* @param mixed $collection | ||
* @param string $dir | ||
* @return Stock | ||
*/ | ||
public function aroundAddValueSortToCollection( | ||
Stock $subject, | ||
callable $proceed, | ||
Collection $collection, | ||
string $dir | ||
): Stock { | ||
if ($collection->getStoreId() !== Store::DEFAULT_STORE_ID) { | ||
$websiteId = $this->storeManager->getStore($collection->getStoreId())->getWebsiteId(); | ||
$websiteCode = $this->storeManager->getWebsite($websiteId)->getCode(); | ||
$stock = $this->stockResolver->execute(SalesChannelInterface::TYPE_WEBSITE, $websiteCode); | ||
$stockId = (int) $stock->getStockId(); | ||
if ($this->defaultStockProvider->getId() !== $stockId) { | ||
$this->addSortByStockQtyToCollection->execute($collection, $dir, $stockId); | ||
return $subject; | ||
} | ||
} | ||
|
||
return $proceed($collection, $dir); | ||
} | ||
} |
Oops, something went wrong.