Skip to content

Commit

Permalink
Merge pull request #70 from gabrieldagama/php8-2.4-sync
Browse files Browse the repository at this point in the history
Php8 2.4 sync
  • Loading branch information
gabrieldagama authored Feb 15, 2021
2 parents b793316 + edb54d2 commit d7bfbd4
Show file tree
Hide file tree
Showing 93 changed files with 1,089 additions and 310 deletions.
22 changes: 11 additions & 11 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ For more detailed information on contribution please read our [beginners guide](

## Contribution requirements

1. Contributions must adhere to the [Magento coding standards](https://devdocs.magento.com/guides/v2.3/coding-standards/bk-coding-standards.html).
2. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances of a pull request being merged quickly and without additional clarification requests.
3. Commits must be accompanied by meaningful commit messages. Please see the [Magento Inventory Pull Request Template](https://github.com/magento/inventory/blob/1.1-develop/.github/PULL_REQUEST_TEMPLATE.md) for more information.
4. PRs which include bug fixes must be accompanied with a step-by-step description of how to reproduce the bug.
3. PRs which include new logic or new features must be submitted along with:
* Unit/integration test coverage
* Proposed [documentation](https://devdocs.magento.com) updates. Documentation contributions can be submitted via the [devdocs GitHub](https://github.com/magento/devdocs).
4. For larger features or changes, please [open an issue](https://github.com/magento/inventory/issues) to discuss the proposed changes prior to development. This may prevent duplicate or unnecessary effort and allow other contributors to provide input.
5. All automated tests must pass.
1. Contributions must adhere to the [Magento coding standards](https://devdocs.magento.com/guides/v2.4/coding-standards/bk-coding-standards.html).
1. Pull requests (PRs) must be accompanied by a meaningful description of their purpose. Comprehensive descriptions increase the chances of a pull request being merged quickly and without additional clarification requests.
1. Commits must be accompanied by meaningful commit messages. Please see the [Magento Inventory Pull Request Template](https://github.com/magento/inventory/blob/1.1-develop/.github/PULL_REQUEST_TEMPLATE.md) for more information.
1. PRs which include bug fixes must be accompanied with a step-by-step description of how to reproduce the bug.
1. PRs which include new logic or new features must be submitted along with:
* Unit/integration test coverage
* Proposed [documentation](https://devdocs.magento.com) updates. Documentation contributions can be submitted via the [devdocs GitHub](https://github.com/magento/devdocs).
1. For larger features or changes, please [open an issue](https://github.com/magento/inventory/issues) to discuss the proposed changes prior to development. This may prevent duplicate or unnecessary effort and allow other contributors to provide input.
1. All automated tests must pass.

## Contribution process

Expand All @@ -33,15 +33,15 @@ This will allow you to collaborate with the Magento 2 development team, fork the
1. Search current [listed issues](https://github.com/magento/inventory/issues) (open or closed) for similar proposals of intended contribution before starting work on a new contribution.
2. Review the [Contributor License Agreement](https://opensource.adobe.com/cla.html) if this is your first time contributing.
3. Create and test your work.
4. Fork the Magento Inventory repository according to the [Fork a Repository instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow the [Create a Pull Request instructions](https://devdocs.magento.com/guides/v2.3/contributor-guide/contributing.html#pull_request).
4. Fork the Magento Inventory repository according to the [Fork a Repository instructions](https://devdocs.magento.com/guides/v2.4/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow the [Create a Pull Request instructions](https://devdocs.magento.com/guides/v2.4/contributor-guide/contributing.html#pull_request).
5. Once your contribution is received the Magento Inventory development team will review the contribution and collaborate with you as needed.

## Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. We expect you to agree to its terms when participating in this project.
The full text is available in the repository [Wiki](https://github.com/magento/magento2/wiki/Magento-Code-of-Conduct).

## Connecting with Community!
## Connecting with Community

If you have any questions, join us in [#beginners](https://magentocommeng.slack.com/messages/CH8BGFX9D) Slack chat. If you are not on our slack, [click here](https://opensource.magento.com/slack) to join.

Expand Down
12 changes: 6 additions & 6 deletions Inventory/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

The `Inventory` module is part of the new inventory infrastructure,
which replaces the legacy `CatalogInventory` module with new and expanded features and APIs for Inventory Management.
The [Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)

The [Inventory Management overview](https://devdocs.magento.com/guides/v2.4/inventory/index.html)
describes the MSI (Multi-Source Inventory) project in more detail.

All Inventory Management modules follow the
All Inventory Management modules follow the
[Single Responsibility Principle](https://en.wikipedia.org/wiki/Single_responsibility_principle).
[Inventory management architecture](https://devdocs.magento.com/guides/v2.3/inventory/architecture.html)
[Inventory management architecture](https://devdocs.magento.com/guides/v2.4/inventory/architecture.html)
provides additional insight about the overall structure of these modules.

## Installation details
Expand All @@ -18,6 +18,6 @@ by a 3rd-party module, the module cannot be deleted or disabled.

## Extension points and service contracts

Magento does not recommend using or referring to classes and other entities in the `Inventory` module. All public
interfaces and extension points related to this module are located in the `InventoryApi` module.
Magento does not recommend using or referring to classes and other entities in the `Inventory` module. All public
interfaces and extension points related to this module are located in the `InventoryApi` module.
Use the interfaces and extension points defined in `InventoryApi` to extend this module.
2 changes: 1 addition & 1 deletion InventoryAdminUi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The `InventoryAdminUi` module extends the Magento Admin UI to add Inventory Management functionality.

This module is part of the new inventory infrastructure. The
[Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)
[Inventory Management overview](https://devdocs.magento.com/guides/v2.4/inventory/index.html)
describes the MSI (Multi-Source Inventory) project in more detail.

## Installation details
Expand Down
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>
4 changes: 2 additions & 2 deletions InventoryApi/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# InventoryApi module

The `InventoryApi` module provides Inventory Management service contracts.
The `InventoryApi` module provides Inventory Management service contracts.

This module is part of the new inventory infrastructure. The
[Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)
[Inventory Management overview](https://devdocs.magento.com/guides/v2.4/inventory/index.html)
describes the MSI (Multi-Source Inventory) project in more detail.

## Installation details
Expand Down
2 changes: 1 addition & 1 deletion InventoryBundleImportExport/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The `InventoryBundleImportExport` module integrates inventory management business logic into Magento's bundle product logic.

This module is part of the new inventory infrastructure. The
[Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)
[Inventory Management overview](https://devdocs.magento.com/guides/v2.4/inventory/index.html)
describes the MSI (Multi-Source Inventory) project in more detail.

## Installation details
Expand Down
2 changes: 1 addition & 1 deletion InventoryBundleProduct/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The `InventoryBundleProduct` module integrates inventory management business logic into Magento's bundle product logic.

This module is part of the new inventory infrastructure. The
[Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)
[Inventory Management overview](https://devdocs.magento.com/guides/v2.4/inventory/index.html)
describes the MSI (Multi-Source Inventory) project in more detail.

## Installation details
Expand Down
4 changes: 2 additions & 2 deletions InventoryBundleProductAdminUi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
The `InventoryBundleProductAdminUi`extends the Magento Admin UI to add MSI functionality.

This module is part of the new inventory infrastructure. The
[Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)
[Inventory Management overview](https://devdocs.magento.com/guides/v2.4/inventory/index.html)
describes the MSI (Multi-Source Inventory) project in more detail.

## Installation details

This module is installed as part of Magento Open Source. It may be disabled if the Inventory Management UI
is provided by a 3rd-party system or if you run a headless version of Magento.

## Extensibility

There are no extension points or for this module.
2 changes: 1 addition & 1 deletion InventoryBundleProductIndexer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The `InventoryBundleProductIndexer` module integrates inventory management business logic into Magento's indexation logic for bundle products.

This module is part of the new inventory infrastructure. The
[Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)
[Inventory Management overview](https://devdocs.magento.com/guides/v2.4/inventory/index.html)
describes the MSI (Multi-Source Inventory) project in more detail.

## Installation details
Expand Down
2 changes: 1 addition & 1 deletion InventoryCache/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
The `InventoryCache` module integrates inventory management business logic into Magento's cache logic.

This module is part of the new inventory infrastructure. The
[Inventory Management overview](https://devdocs.magento.com/guides/v2.3/inventory/index.html)
[Inventory Management overview](https://devdocs.magento.com/guides/v2.4/inventory/index.html)
describes the MSI (Multi-Source Inventory) project in more detail.

## Installation details
Expand Down
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}");
}
}
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);
}
}
Loading

0 comments on commit d7bfbd4

Please sign in to comment.