Skip to content

Commit e816892

Browse files
Merge branch '2.4-develop' into SEARCH-1968-static-test-check-dependencies
2 parents 70ae05d + 83f3d01 commit e816892

File tree

26 files changed

+920
-62
lines changed

26 files changed

+920
-62
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Authorization\Test\Fixture;
9+
10+
use Magento\Authorization\Model\Acl\Role\Group;
11+
use Magento\Authorization\Model\ResourceModel\Role as RoleResource;
12+
use Magento\Authorization\Model\UserContextInterface;
13+
use Magento\Framework\DataObject;
14+
use Magento\SharedCatalog\Model\SharedCatalogFactory;
15+
use Magento\TestFramework\Fixture\Data\ProcessorInterface;
16+
use Magento\TestFramework\Fixture\RevertibleDataFixtureInterface;
17+
use Magento\Authorization\Model\RoleFactory;
18+
use Magento\Authorization\Model\RulesFactory;
19+
use Magento\User\Model\UserFactory;
20+
21+
/**
22+
* Creating a new admin role
23+
*/
24+
class Role implements RevertibleDataFixtureInterface
25+
{
26+
private const DEFAULT_DATA = [
27+
'role_name' => 'Role Name %uniqid%',
28+
'role_type' => Group::ROLE_TYPE,
29+
'user_id' => 0,
30+
'user_type' => UserContextInterface::USER_TYPE_ADMIN
31+
];
32+
33+
private const DEFAULT_DATA_RULES = [
34+
'id' => null,
35+
'role_id' => null,
36+
'resources' => ['Magento_Backend::all']
37+
];
38+
39+
/**
40+
* @var RoleFactory
41+
*/
42+
private $roleFactory;
43+
44+
/**
45+
* @var ProcessorInterface
46+
*/
47+
private $dataProcessor;
48+
49+
/**
50+
* @var RoleResource
51+
*/
52+
private $roleResourceModel;
53+
54+
/**
55+
* @var RulesFactory
56+
*/
57+
private $rulesFactory;
58+
59+
/**
60+
* @param RoleFactory $roleFactory
61+
* @param RoleResource $roleResourceModel
62+
* @param RulesFactory $rulesFactory
63+
* @param ProcessorInterface $dataProcessor
64+
*/
65+
public function __construct(
66+
RoleFactory $roleFactory,
67+
RoleResource $roleResourceModel,
68+
RulesFactory $rulesFactory,
69+
ProcessorInterface $dataProcessor
70+
) {
71+
$this->roleFactory = $roleFactory;
72+
$this->roleResourceModel = $roleResourceModel;
73+
$this->rulesFactory = $rulesFactory;
74+
$this->dataProcessor = $dataProcessor;
75+
}
76+
77+
/**
78+
* @inheritdoc
79+
*/
80+
public function apply(array $data = []): ?DataObject
81+
{
82+
$role = $this->roleFactory->create();
83+
$role->setData($this->prepareData(array_diff_key($data, self::DEFAULT_DATA_RULES)));
84+
$this->roleResourceModel->save($role);
85+
86+
$rules = $this->rulesFactory->create();
87+
$rules->setRoleId($role->getId() ?? null);
88+
$rules->setResources($data['resources'] ?? self::DEFAULT_DATA_RULES['resources']);
89+
$rules->saveRel();
90+
91+
return $role;
92+
}
93+
94+
/**
95+
* @inheritdoc
96+
*/
97+
public function revert(DataObject $data): void
98+
{
99+
$role = $this->roleFactory->create();
100+
$role->load($data->getId());
101+
102+
if ($role->getId() !== null) {
103+
$role->delete();
104+
}
105+
}
106+
107+
/**
108+
* Prepare admin role data
109+
*
110+
* @param array $data
111+
* @return array
112+
*/
113+
private function prepareData(array $data): array
114+
{
115+
$data = array_merge(self::DEFAULT_DATA, $data);
116+
return $this->dataProcessor->process($this, $data);
117+
}
118+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare (strict_types=1);
8+
namespace Magento\Catalog\Model\ResourceModel;
9+
10+
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Framework\App\ResourceConnection;
12+
13+
/**
14+
* Get product type ID by product ID.
15+
*/
16+
class GetProductTypeById
17+
{
18+
/**
19+
* @var ResourceConnection
20+
*/
21+
private $resource;
22+
23+
/**
24+
* @param ResourceConnection $resource
25+
*/
26+
public function __construct(
27+
ResourceConnection $resource
28+
) {
29+
$this->resource = $resource;
30+
}
31+
32+
/**
33+
* Retrieve product type by its product ID
34+
*
35+
* @param int $productId
36+
* @return string
37+
*/
38+
public function execute(int $productId): string
39+
{
40+
$connection = $this->resource->getConnection();
41+
$productTable = $this->resource->getTableName('catalog_product_entity');
42+
43+
$select = $connection->select()
44+
->from(
45+
$productTable,
46+
ProductInterface::TYPE_ID
47+
)->where('entity_id = ?', $productId);
48+
49+
$result = $connection->fetchOne($select);
50+
return $result ?: '';
51+
}
52+
}

app/code/Magento/CatalogGraphQl/Model/Resolver/Products/DataProvider/Product/CollectionProcessor/StockProcessor.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,10 @@ public function process(
5757
array $attributeNames,
5858
ContextInterface $context = null
5959
): Collection {
60-
if (!$this->stockConfig->isShowOutOfStock()) {
61-
$this->stockStatusResource->addIsInStockFilterToCollection($collection);
60+
$stockFlag = 'has_stock_status_filter';
61+
if (!$collection->hasFlag($stockFlag)) {
62+
$this->stockStatusResource->addStockDataToCollection($collection, !$this->stockConfig->isShowOutOfStock());
63+
$collection->setFlag($stockFlag, true);
6264
}
6365

6466
return $collection;

app/code/Magento/Checkout/Test/Mftf/Section/CheckoutShippingMethodsSection.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@
2222
<element name="noQuotesMsg" type="text" selector="#checkout-step-shipping_method div"/>
2323
<element name="price" type="text" selector="//*[@id='checkout-shipping-method-load']//td[@class='col col-price']"/>
2424
<element name="shippingRatePriceByName" type="text" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/..//td//span[contains(@class, 'price')]" parameterized="true"/>
25+
<element name="showShippingVatNumber" type="text" selector="div.shipping-address-item"/>
26+
<element name="showBillingVatNumber" type="text" selector="div.billing-address-details"/>
27+
<element name="showShippingInfoVatNumber" type="text" selector="div.shipping-information-content"/>
2528
</section>
2629
</sections>

app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,21 @@
77
<div if="isAddressDetailsVisible() && currentBillingAddress()" class="billing-address-details">
88
<text args="currentBillingAddress().prefix"></text> <text args="currentBillingAddress().firstname"></text>
99
<text args="currentBillingAddress().middlename"></text>
10-
<text args="currentBillingAddress().lastname"></text> <text args="currentBillingAddress().suffix"></text><br/>
11-
<text args="_.values(currentBillingAddress().street).join(', ')"></text><br/>
10+
<text args="currentBillingAddress().lastname"></text> <text args="currentBillingAddress().suffix"></text><br>
11+
<if args="currentBillingAddress().company">
12+
<text args="currentBillingAddress().company"></text><br>
13+
</if>
14+
<text args="_.values(currentBillingAddress().street).join(', ')"></text><br>
1215
<text args="currentBillingAddress().city "></text>, <span text="currentBillingAddress().region"></span>
13-
<text args="currentBillingAddress().postcode"></text><br/>
14-
<text args="getCountryName(currentBillingAddress().countryId)"></text><br/>
15-
<a if="currentBillingAddress().telephone" attr="'href': 'tel:' + currentBillingAddress().telephone" text="currentBillingAddress().telephone"></a><br/>
16-
16+
<text args="currentBillingAddress().postcode"></text><br>
17+
<text args="getCountryName(currentBillingAddress().countryId)"></text><br>
18+
<a if="currentBillingAddress().telephone" attr="'href': 'tel:' + currentBillingAddress().telephone" text="currentBillingAddress().telephone"></a><br>
19+
<if args="currentBillingAddress().vatId">
20+
VAT: <text args="currentBillingAddress().vatId"></text><br>
21+
</if>
1722
<each args="data: currentBillingAddress().customAttributes, as: 'element'">
1823
<text args="$parent.getCustomAttributeLabel(element)"></text>
19-
<br/>
24+
<br>
2025
</each>
2126

2227
<button visible="!isAddressSameAsShipping()"

app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
-->
77
<div class="shipping-address-item" css="'selected-item' : isSelected() , 'not-selected-item':!isSelected()">
88
<text args="address().prefix"></text> <text args="address().firstname"></text> <text args="address().middlename"></text>
9-
<text args="address().lastname"></text> <text args="address().suffix"></text><br/>
10-
<text args="_.values(address().street).join(', ')"></text><br/>
11-
<text args="address().city "></text>, <span text="address().region"></span> <text args="address().postcode"></text><br/>
12-
<text args="getCountryName(address().countryId)"></text><br/>
13-
<a if="address().telephone" attr="'href': 'tel:' + address().telephone" text="address().telephone"></a><br/>
14-
9+
<text args="address().lastname"></text> <text args="address().suffix"></text><br>
10+
<if args="address().company">
11+
<text args="address().company"></text><br>
12+
</if>
13+
<text args="_.values(address().street).join(', ')"></text><br>
14+
<text args="address().city "></text>, <span text="address().region"></span> <text args="address().postcode"></text><br>
15+
<text args="getCountryName(address().countryId)"></text><br>
16+
<a if="address().telephone" attr="'href': 'tel:' + address().telephone" text="address().telephone"></a><br>
17+
<if args="address().vatId">
18+
VAT: <text args="address().vatId"></text><br>
19+
</if>
1520
<each args="data: address().customAttributes, as: 'element'">
1621
<text args="$parent.getCustomAttributeLabel(element)"></text>
17-
<br/>
22+
<br>
1823
</each>
1924

2025
<button visible="address().isEditable()" type="button"

app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,19 @@
66
-->
77
<if args="visible()">
88
<text args="address().prefix"></text> <text args="address().firstname"></text> <text args="address().middlename"></text>
9-
<text args="address().lastname"></text> <text args="address().suffix"></text><br/>
10-
<text args="_.values(address().street).join(', ')"></text><br/>
11-
<text args="address().city "></text>, <span text="address().region"></span> <text args="address().postcode"></text><br/>
12-
<text args="getCountryName(address().countryId)"></text><br/>
13-
<a if="address().telephone" attr="'href': 'tel:' + address().telephone" text="address().telephone"></a><br/>
14-
9+
<text args="address().lastname"></text> <text args="address().suffix"></text><br>
10+
<if args="address().company">
11+
<text args="address().company"></text><br>
12+
</if>
13+
<text args="_.values(address().street).join(', ')"></text><br>
14+
<text args="address().city "></text>, <span text="address().region"></span> <text args="address().postcode"></text><br>
15+
<text args="getCountryName(address().countryId)"></text><br>
16+
<a if="address().telephone" attr="'href': 'tel:' + address().telephone" text="address().telephone"></a><br>
17+
<if args="address().vatId">
18+
VAT: <text args="address().vatId"></text><br>
19+
</if>
1520
<each args="data: address().customAttributes, as: 'element'">
1621
<text args="$parent.getCustomAttributeLabel(element)"></text>
17-
<br/>
22+
<br>
1823
</each>
1924
</if>

app/code/Magento/ConfigurableProduct/Model/Inventory/ChangeParentStockStatus.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ private function processStockForParent(int $productId): void
106106
if ($this->isNeedToUpdateParent($parentStockItem, $childrenIsInStock)) {
107107
$parentStockItem->setIsInStock($childrenIsInStock);
108108
$parentStockItem->setStockStatusChangedAuto(1);
109+
$parentStockItem->setStockStatusChangedAutomaticallyFlag(true);
109110
$this->stockItemRepository->save($parentStockItem);
110111
}
111112
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare (strict_types=1);
8+
namespace Magento\ConfigurableProduct\Model\Plugin;
9+
10+
use Magento\Catalog\Model\ResourceModel\GetProductTypeById;
11+
use Magento\CatalogInventory\Model\ResourceModel\Stock\Item as ItemResourceModel;
12+
use Magento\Framework\Model\AbstractModel as StockItem;
13+
use Magento\ConfigurableProduct\Model\Product\Type\Configurable;
14+
15+
/**
16+
* Updates stock_status_changed_auto setting for configurable product when it was saved manually
17+
*/
18+
class UpdateStockChangedAuto
19+
{
20+
/**
21+
* @var GetProductTypeById
22+
*/
23+
private $getProductTypeById;
24+
25+
/**
26+
* @param GetProductTypeById $getProductTypeById
27+
*/
28+
public function __construct(GetProductTypeById $getProductTypeById)
29+
{
30+
$this->getProductTypeById = $getProductTypeById;
31+
}
32+
33+
/**
34+
* Updates stock_status_changed_auto for configurable product
35+
*
36+
* @param ItemResourceModel $subject
37+
* @param StockItem $stockItem
38+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
39+
*/
40+
public function beforeSave(ItemResourceModel $subject, StockItem $stockItem): void
41+
{
42+
if (!$stockItem->getIsInStock() &&
43+
!$stockItem->hasStockStatusChangedAutomaticallyFlag() &&
44+
$this->getProductTypeById->execute($stockItem->getProductId()) == Configurable::TYPE_CODE
45+
) {
46+
$stockItem->setStockStatusChangedAuto(0);
47+
}
48+
}
49+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\ConfigurableProduct\Pricing\Price;
9+
10+
use Magento\Catalog\Api\Data\ProductInterface;
11+
use Magento\Framework\Exception\InvalidArgumentException;
12+
13+
class ConfigurableOptionsCompositeFilter implements ConfigurableOptionsFilterInterface
14+
{
15+
/**
16+
* @var ConfigurableOptionsFilterInterface[]
17+
*/
18+
private $configurableOptionsFilters;
19+
20+
/**
21+
* @param ConfigurableOptionsFilterInterface[] $configurableOptionsFilters
22+
* @throws InvalidArgumentException
23+
*/
24+
public function __construct(
25+
array $configurableOptionsFilters = []
26+
) {
27+
foreach ($configurableOptionsFilters as $configurableOptionsFilter) {
28+
if (!$configurableOptionsFilter instanceof ConfigurableOptionsFilterInterface) {
29+
throw new InvalidArgumentException(
30+
__(
31+
'Filter %1 doesn\'t implement %2',
32+
get_class($configurableOptionsFilter),
33+
ConfigurableOptionsFilterInterface::class
34+
)
35+
);
36+
}
37+
}
38+
$this->configurableOptionsFilters = $configurableOptionsFilters;
39+
}
40+
41+
/**
42+
* @inheritdoc
43+
*/
44+
public function filter(ProductInterface $parentProduct, array $childProducts): array
45+
{
46+
foreach ($this->configurableOptionsFilters as $configurableOptionsFilter) {
47+
$childProducts = $configurableOptionsFilter->filter($parentProduct, $childProducts);
48+
}
49+
return $childProducts;
50+
}
51+
}

0 commit comments

Comments
 (0)