Skip to content

Commit 62b7e03

Browse files
committed
Merge branch 'MC-29293' into 2.3-develop-com-pr10
2 parents b5358cd + 0743f12 commit 62b7e03

File tree

16 files changed

+1044
-31
lines changed

16 files changed

+1044
-31
lines changed

app/code/Magento/Catalog/view/frontend/web/template/product/image_with_borders.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
-->
77
<span class="product-image-container" data-bind="style: {width: width + 'px'}">
88
<span class="product-image-wrapper" data-bind="style: {'padding-bottom': height/width*100 + '%'}">
9-
<img class="product-image-photo" data-bind="attr: {src: src, alt: alt}, style: {width: width + 'px', height: height + 'px'}" />
9+
<img class="product-image-photo" data-bind="attr: {src: src, alt: alt}, style: {width: 'auto', height: 'auto'}" />
1010
</span>
1111
</span>

app/code/Magento/Customer/etc/fieldset.xml

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,6 @@
5757
<aspect name="update" />
5858
</field>
5959
</fieldset>
60-
<fieldset id="customer_address">
61-
<field name="vat_id">
62-
<aspect name="to_quote_address" />
63-
</field>
64-
<field name="vat_is_valid">
65-
<aspect name="to_quote_address" />
66-
</field>
67-
<field name="vat_request_id">
68-
<aspect name="to_quote_address" />
69-
</field>
70-
<field name="vat_request_date">
71-
<aspect name="to_quote_address" />
72-
</field>
73-
<field name="vat_request_success">
74-
<aspect name="to_quote_address" />
75-
</field>
76-
</fieldset>
7760
<fieldset id="sales_convert_order_address">
7861
<field name="vat_id">
7962
<aspect name="to_quote_address" />

app/code/Magento/Quote/Model/ShippingMethodManagement.php

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
namespace Magento\Quote\Model;
88

99
use Magento\Customer\Api\Data\AddressInterfaceFactory;
10+
use Magento\Customer\Model\Session as CustomerSession;
1011
use Magento\Framework\App\ObjectManager;
1112
use Magento\Framework\Exception\CouldNotSaveException;
1213
use Magento\Framework\Exception\InputException;
@@ -22,6 +23,7 @@
2223
* Shipping method read service
2324
*
2425
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
26+
* @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
2527
*/
2628
class ShippingMethodManagement implements
2729
\Magento\Quote\Api\ShippingMethodManagementInterface,
@@ -69,6 +71,11 @@ class ShippingMethodManagement implements
6971
*/
7072
private $quoteAddressResource;
7173

74+
/**
75+
* @var CustomerSession
76+
*/
77+
private $customerSession;
78+
7279
/**
7380
* Constructor
7481
*
@@ -78,14 +85,16 @@ class ShippingMethodManagement implements
7885
* @param Quote\TotalsCollector $totalsCollector
7986
* @param AddressInterfaceFactory|null $addressFactory
8087
* @param QuoteAddressResource|null $quoteAddressResource
88+
* @param CustomerSession|null $customerSession
8189
*/
8290
public function __construct(
8391
\Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
8492
Cart\ShippingMethodConverter $converter,
8593
\Magento\Customer\Api\AddressRepositoryInterface $addressRepository,
8694
\Magento\Quote\Model\Quote\TotalsCollector $totalsCollector,
8795
AddressInterfaceFactory $addressFactory = null,
88-
QuoteAddressResource $quoteAddressResource = null
96+
QuoteAddressResource $quoteAddressResource = null,
97+
CustomerSession $customerSession = null
8998
) {
9099
$this->quoteRepository = $quoteRepository;
91100
$this->converter = $converter;
@@ -95,10 +104,11 @@ public function __construct(
95104
->get(AddressInterfaceFactory::class);
96105
$this->quoteAddressResource = $quoteAddressResource ?: ObjectManager::getInstance()
97106
->get(QuoteAddressResource::class);
107+
$this->customerSession = $customerSession ?? ObjectManager::getInstance()->get(CustomerSession::class);
98108
}
99109

100110
/**
101-
* {@inheritDoc}
111+
* @inheritDoc
102112
*/
103113
public function get($cartId)
104114
{
@@ -126,7 +136,7 @@ public function get($cartId)
126136
}
127137

128138
/**
129-
* {@inheritDoc}
139+
* @inheritDoc
130140
*/
131141
public function getList($cartId)
132142
{
@@ -155,7 +165,7 @@ public function getList($cartId)
155165
}
156166

157167
/**
158-
* {@inheritDoc}
168+
* @inheritDoc
159169
*/
160170
public function set($cartId, $carrierCode, $methodCode)
161171
{
@@ -176,6 +186,8 @@ public function set($cartId, $carrierCode, $methodCode)
176186
}
177187

178188
/**
189+
* Apply carrier code.
190+
*
179191
* @param int $cartId The shopping cart ID.
180192
* @param string $carrierCode The carrier code.
181193
* @param string $methodCode The shipping method code.
@@ -209,7 +221,7 @@ public function apply($cartId, $carrierCode, $methodCode)
209221
}
210222

211223
/**
212-
* {@inheritDoc}
224+
* @inheritDoc
213225
*/
214226
public function estimateByAddress($cartId, \Magento\Quote\Api\Data\EstimateAddressInterface $address)
215227
{
@@ -240,7 +252,7 @@ public function estimateByExtendedAddress($cartId, AddressInterface $address)
240252
}
241253

242254
/**
243-
* {@inheritDoc}
255+
* @inheritDoc
244256
*/
245257
public function estimateByAddressId($cartId, $addressId)
246258
{
@@ -266,6 +278,7 @@ public function estimateByAddressId($cartId, $addressId)
266278
* @param string $region
267279
* @param \Magento\Framework\Api\ExtensibleDataInterface|null $address
268280
* @return \Magento\Quote\Api\Data\ShippingMethodInterface[] An array of shipping methods.
281+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
269282
* @deprecated 100.2.0
270283
*/
271284
protected function getEstimatedRates(
@@ -277,11 +290,10 @@ protected function getEstimatedRates(
277290
$address = null
278291
) {
279292
if (!$address) {
280-
$address = $this->getAddressFactory()->create()
293+
$address = $this->addressFactory->create()
281294
->setCountryId($country)
282295
->setPostcode($postcode)
283-
->setRegionId($regionId)
284-
->setRegion($region);
296+
->setRegionId($regionId);
285297
}
286298
return $this->getShippingMethods($quote, $address);
287299
}
@@ -301,12 +313,21 @@ private function getShippingMethods(Quote $quote, $address)
301313
$shippingAddress->setCollectShippingRates(true);
302314

303315
$this->totalsCollector->collectAddressTotals($quote, $shippingAddress);
316+
$quoteCustomerGroupId = $quote->getCustomerGroupId();
317+
$customerGroupId = $this->customerSession->getCustomerGroupId();
318+
$isCustomerGroupChanged = $quoteCustomerGroupId !== $customerGroupId;
319+
if ($isCustomerGroupChanged) {
320+
$quote->setCustomerGroupId($customerGroupId);
321+
}
304322
$shippingRates = $shippingAddress->getGroupedAllShippingRates();
305323
foreach ($shippingRates as $carrierRates) {
306324
foreach ($carrierRates as $rate) {
307325
$output[] = $this->converter->modelToDataObject($rate, $quote->getQuoteCurrencyCode());
308326
}
309327
}
328+
if ($isCustomerGroupChanged) {
329+
$quote->setCustomerGroupId($quoteCustomerGroupId);
330+
}
310331
return $output;
311332
}
312333

app/code/Magento/Wishlist/Controller/Index/Plugin.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Magento\Framework\App\Config\ScopeConfigInterface;
1111
use Magento\Framework\App\RequestInterface;
1212
use Magento\Framework\App\Response\RedirectInterface;
13+
use Magento\Store\Model\ScopeInterface;
1314

1415
/**
1516
* Wishlist plugin before dispatch
@@ -89,7 +90,7 @@ public function beforeDispatch(\Magento\Framework\App\ActionInterface $subject,
8990
$this->messageManager->addErrorMessage(__('You must login or register to add items to your wishlist.'));
9091
}
9192
}
92-
if (!$this->config->isSetFlag('wishlist/general/active')) {
93+
if (!$this->config->isSetFlag('wishlist/general/active', ScopeInterface::SCOPE_STORES)) {
9394
throw new NotFoundException(__('Page not found.'));
9495
}
9596
}

app/code/Magento/Wishlist/Test/Unit/Controller/Index/PluginTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66

77
namespace Magento\Wishlist\Test\Unit\Controller\Index;
88

9+
use Magento\Store\Model\ScopeInterface;
10+
911
/**
1012
* Test for wishlist plugin before dispatch
13+
*
14+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1115
*/
1216
class PluginTest extends \PHPUnit\Framework\TestCase
1317
{
@@ -175,7 +179,7 @@ public function testBeforeDispatch()
175179
$this->config
176180
->expects($this->once())
177181
->method('isSetFlag')
178-
->with('wishlist/general/active')
182+
->with('wishlist/general/active', ScopeInterface::SCOPE_STORES)
179183
->willReturn(false);
180184

181185
$this->getPlugin()->beforeDispatch($indexController, $this->request);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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\TestFramework\ConfigurableProduct\Model;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
12+
use Magento\Framework\Exception\NoSuchEntityException;
13+
use Magento\Framework\Registry;
14+
15+
/**
16+
* Delete configurable product with linked products
17+
*/
18+
class DeleteConfigurableProduct
19+
{
20+
/** @var ProductRepositoryInterface */
21+
private $productRepository;
22+
23+
/** @var ProductResource */
24+
private $productResource;
25+
26+
/** @var Registry */
27+
private $registry;
28+
29+
/**
30+
* @param ProductRepositoryInterface $productRepository
31+
* @param ProductResource $productResource
32+
* @param Registry $registry
33+
*/
34+
public function __construct(
35+
ProductRepositoryInterface $productRepository,
36+
ProductResource $productResource,
37+
Registry $registry
38+
) {
39+
$this->productRepository = $productRepository;
40+
$this->productResource = $productResource;
41+
$this->registry = $registry;
42+
}
43+
44+
/**
45+
* Delete configurable product and linked products
46+
*
47+
* @param string $sku
48+
* @return void
49+
*/
50+
public function execute(string $sku): void
51+
{
52+
$configurableProduct = $this->productRepository->get($sku, false, null, true);
53+
$childrenIds = $configurableProduct->getExtensionAttributes()->getConfigurableProductLinks();
54+
$childrenSkus = array_column($this->productResource->getProductsSku($childrenIds), 'sku');
55+
$childrenSkus[] = $sku;
56+
$this->registry->unregister('isSecureArea');
57+
$this->registry->register('isSecureArea', true);
58+
59+
foreach ($childrenSkus as $childSku) {
60+
try {
61+
$this->productRepository->deleteById($childSku);
62+
} catch (NoSuchEntityException $e) {
63+
//product already removed
64+
}
65+
}
66+
67+
$this->registry->unregister('isSecureArea');
68+
$this->registry->register('isSecureArea', false);
69+
}
70+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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\Block\Product\View\Type;
9+
10+
use Magento\Catalog\Block\Product\ListProduct;
11+
use Magento\Eav\Model\Entity\Collection\AbstractCollection;
12+
use Magento\Framework\ObjectManagerInterface;
13+
use Magento\Framework\View\LayoutInterface;
14+
use Magento\TestFramework\Helper\Bootstrap;
15+
use PHPUnit\Framework\TestCase;
16+
17+
/**
18+
* Class checks configurable product displaying on category view page
19+
*
20+
* @magentoDbIsolation disabled
21+
* @magentoAppIsolation enabled
22+
* @magentoAppArea frontend
23+
* @magentoDataFixture Magento/ConfigurableProduct/_files/configurable_product_with_out_of_stock_children.php
24+
*/
25+
class ConfigurableViewOnCategoryPageTest extends TestCase
26+
{
27+
/** @var ObjectManagerInterface */
28+
private $objectManager;
29+
30+
/** @var LayoutInterface */
31+
private $layout;
32+
33+
/** @var ListProduct $listingBlock */
34+
private $listingBlock;
35+
36+
/**
37+
* @inheritdoc
38+
*/
39+
protected function setUp()
40+
{
41+
parent::setUp();
42+
43+
$this->objectManager = Bootstrap::getObjectManager();
44+
$this->layout = $this->objectManager->get(LayoutInterface::class);
45+
$this->listingBlock = $this->layout->createBlock(ListProduct::class);
46+
$this->listingBlock->setCategoryId(333);
47+
}
48+
49+
/**
50+
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 1
51+
*
52+
* @return void
53+
*/
54+
public function testOutOfStockProductWithEnabledConfigView(): void
55+
{
56+
$collection = $this->listingBlock->getLoadedProductCollection();
57+
$this->assertCollectionSize(1, $collection);
58+
}
59+
60+
/**
61+
* @magentoConfigFixture current_store cataloginventory/options/show_out_of_stock 0
62+
*
63+
* @return void
64+
*/
65+
public function testOutOfStockProductWithDisabledConfigView(): void
66+
{
67+
$collection = $this->listingBlock->getLoadedProductCollection();
68+
$this->assertCollectionSize(0, $collection);
69+
}
70+
71+
/**
72+
* Check collection size
73+
*
74+
* @param int $expectedSize
75+
* @param AbstractCollection $collection
76+
* @return void
77+
*/
78+
private function assertCollectionSize(int $expectedSize, AbstractCollection $collection): void
79+
{
80+
$this->assertEquals($expectedSize, $collection->getSize());
81+
$this->assertCount($expectedSize, $collection->getItems());
82+
}
83+
}

0 commit comments

Comments
 (0)