Skip to content

Commit 9da3944

Browse files
authored
Merge pull request #4595 from magento-tsg/2.3-develop-pr64
[TSG] Fixes for 2.3 (pr64) (2.3-develop)
2 parents 9152b81 + b74c033 commit 9da3944

File tree

9 files changed

+327
-27
lines changed

9 files changed

+327
-27
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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\Catalog\Pricing\Price;
9+
10+
use Magento\Framework\App\ObjectManager;
11+
use Magento\Framework\Pricing\SaleableInterface;
12+
use Magento\Store\Model\StoreManagerInterface;
13+
use Magento\Framework\Pricing\Price\Factory;
14+
use Magento\Framework\Pricing\Price\Pool;
15+
16+
/**
17+
* Price models collection class.
18+
*/
19+
class Collection extends \Magento\Framework\Pricing\Price\Collection
20+
{
21+
/**
22+
* @var StoreManagerInterface
23+
*/
24+
private $storeManager;
25+
26+
/**
27+
* @param SaleableInterface $saleableItem
28+
* @param Factory $priceFactory
29+
* @param Pool $pool
30+
* @param float $quantity
31+
* @param StoreManagerInterface|null $storeManager
32+
*/
33+
public function __construct(
34+
SaleableInterface $saleableItem,
35+
Factory $priceFactory,
36+
Pool $pool,
37+
$quantity,
38+
StoreManagerInterface $storeManager = null
39+
) {
40+
parent::__construct($saleableItem, $priceFactory, $pool, $quantity);
41+
$this->storeManager = $storeManager ?? ObjectManager::getInstance()->get(StoreManagerInterface::class);
42+
}
43+
44+
/**
45+
* @inheritdoc
46+
*/
47+
public function get($code)
48+
{
49+
$customerGroupId = $this->saleableItem->getCustomerGroupId() ?? '';
50+
$websiteId = $this->storeManager->getStore($this->saleableItem->getStoreId())->getWebsiteId();
51+
$codeKey = $code . '-' . $customerGroupId . '-' . $websiteId;
52+
53+
if (!isset($this->priceModels[$codeKey])) {
54+
$this->priceModels[$codeKey] = $this->priceFactory->create(
55+
$this->saleableItem,
56+
$this->pool[$code],
57+
$this->quantity
58+
);
59+
}
60+
61+
return $this->priceModels[$codeKey];
62+
}
63+
}

app/code/Magento/Catalog/Pricing/Render/FinalPriceBox.php

+9-7
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(
6060
}
6161

6262
/**
63-
* @return string
63+
* @inheritdoc
6464
*/
6565
protected function _toHtml()
6666
{
@@ -182,25 +182,27 @@ public function showMinimalPrice()
182182
*/
183183
public function getCacheKey()
184184
{
185-
return parent::getCacheKey() . ($this->getData('list_category_page') ? '-list-category-page': '');
185+
return parent::getCacheKey()
186+
. ($this->getData('list_category_page') ? '-list-category-page': '')
187+
. ($this->getSaleableItem()->getCustomerGroupId() ?? '');
186188
}
187189

188190
/**
189-
* {@inheritdoc}
190-
*
191-
* @return array
191+
* @inheritdoc
192192
*/
193193
public function getCacheKeyInfo()
194194
{
195195
$cacheKeys = parent::getCacheKeyInfo();
196196
$cacheKeys['display_minimal_price'] = $this->getDisplayMinimalPrice();
197197
$cacheKeys['is_product_list'] = $this->isProductList();
198+
$cacheKeys['customer_group_id'] = $this->getSaleableItem()->getCustomerGroupId();
198199
return $cacheKeys;
199200
}
200201

201202
/**
202-
* Get flag that price rendering should be done for the list of products
203-
* By default (if flag is not set) is false
203+
* Get flag that price rendering should be done for the list of products.
204+
*
205+
* By default (if flag is not set) is false.
204206
*
205207
* @return bool
206208
*/

app/code/Magento/Catalog/etc/di.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,11 @@
377377
</argument>
378378
</arguments>
379379
</virtualType>
380-
<virtualType name="Magento\Catalog\Pricing\Price\Collection" type="Magento\Framework\Pricing\Price\Collection">
380+
<type name="Magento\Catalog\Pricing\Price\Collection">
381381
<arguments>
382382
<argument name="pool" xsi:type="object">Magento\Catalog\Pricing\Price\Pool</argument>
383383
</arguments>
384-
</virtualType>
384+
</type>
385385
<type name="Magento\Framework\Pricing\PriceInfo\Factory">
386386
<arguments>
387387
<argument name="types" xsi:type="array">

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart/Sidebar.php

+3
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ public function openMiniCart()
115115
if (!$this->browser->find($this->cartContent)->isVisible()) {
116116
$this->browser->find($this->cartLink)->click();
117117
}
118+
// Need this because there are a lot of JS processes that update shopping cart items
119+
// and we cant control them all
120+
sleep(5);
118121
}
119122

120123
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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+
use Magento\Catalog\Api\Data\ProductTierPriceExtensionFactory;
9+
use Magento\Catalog\Api\Data\ProductExtensionInterfaceFactory;
10+
use Magento\Catalog\Api\Data\ProductTierPriceInterfaceFactory;
11+
use Magento\Catalog\Api\ProductRepositoryInterface;
12+
use Magento\Catalog\Model\Product;
13+
use Magento\Catalog\Model\Product\Attribute\Source\Status;
14+
use Magento\Catalog\Model\Product\Type;
15+
use Magento\Catalog\Model\Product\Visibility;
16+
use Magento\Store\Api\WebsiteRepositoryInterface;
17+
use Magento\TestFramework\Helper\Bootstrap;
18+
19+
/** @var \Magento\TestFramework\ObjectManager $objectManager */
20+
$objectManager = Bootstrap::getObjectManager();
21+
22+
/** @var ProductTierPriceInterfaceFactory $tierPriceFactory */
23+
$tierPriceFactory = $objectManager->get(ProductTierPriceInterfaceFactory::class);
24+
/** @var $tpExtensionAttributes */
25+
$tpExtensionAttributesFactory = $objectManager->get(ProductTierPriceExtensionFactory::class);
26+
/** @var $productExtensionAttributes */
27+
$productExtensionAttributesFactory = $objectManager->get(ProductExtensionInterfaceFactory::class);
28+
29+
$adminWebsite = $objectManager->get(WebsiteRepositoryInterface::class)->get('admin');
30+
$tierPriceExtensionAttributes1 = $tpExtensionAttributesFactory->create()
31+
->setWebsiteId($adminWebsite->getId());
32+
$productExtensionAttributesWebsiteIds = $productExtensionAttributesFactory->create(
33+
['website_ids' => $adminWebsite->getId()]
34+
);
35+
36+
$tierPrice = $tierPriceFactory->create(
37+
[
38+
'data' => [
39+
'customer_group_id' => 2,
40+
'qty' => 1,
41+
'value' => 5,
42+
],
43+
]
44+
)->setExtensionAttributes($tierPriceExtensionAttributes1);
45+
46+
/** @var $product Product */
47+
$product = $objectManager->create(Product::class);
48+
$product->isObjectNew(true);
49+
$product->setTypeId(Type::TYPE_SIMPLE)
50+
->setAttributeSetId($product->getDefaultAttributeSetId())
51+
->setWebsiteIds([$adminWebsite->getId()])
52+
->setName('Simple Product')
53+
->setSku('simple')
54+
->setPrice(10)
55+
->setWeight(1)
56+
->setShortDescription("Short description")
57+
->setTaxClassId(0)
58+
->setTierPrices([$tierPrice])
59+
->setDescription('Description with <b>html tag</b>')
60+
->setExtensionAttributes($productExtensionAttributesWebsiteIds)
61+
->setMetaTitle('meta title')
62+
->setMetaKeyword('meta keyword')
63+
->setMetaDescription('meta description')
64+
->setVisibility(Visibility::VISIBILITY_BOTH)
65+
->setStatus(Status::STATUS_ENABLED)
66+
->setStockData(
67+
[
68+
'use_config_manage_stock' => 1,
69+
'qty' => 100,
70+
'is_qty_decimal' => 0,
71+
'is_in_stock' => 1,
72+
]
73+
)->setCanSaveCustomOptions(true)
74+
->setHasOptions(true);
75+
76+
/** @var ProductRepositoryInterface $productRepository */
77+
$productRepository = $objectManager->create(ProductRepositoryInterface::class);
78+
$productRepository->save($product);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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+
use Magento\Catalog\Api\ProductRepositoryInterface;
9+
use Magento\Framework\Exception\NoSuchEntityException;
10+
use Magento\Framework\Registry;
11+
use Magento\TestFramework\Helper\Bootstrap;
12+
13+
/** @var Registry $registry */
14+
$registry = Bootstrap::getObjectManager()->get(Registry::class);
15+
16+
$registry->unregister('isSecureArea');
17+
$registry->register('isSecureArea', true);
18+
19+
/** @var ProductRepositoryInterface $productRepository */
20+
$productRepository = Bootstrap::getObjectManager()
21+
->get(ProductRepositoryInterface::class);
22+
try {
23+
$product = $productRepository->get('simple', false, null, true);
24+
$productRepository->delete($product);
25+
} catch (NoSuchEntityException $e) {
26+
}
27+
$registry->unregister('isSecureArea');
28+
$registry->register('isSecureArea', false);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Fixture for Customer List method.
4+
*
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
declare(strict_types = 1);
9+
10+
use Magento\Customer\Model\Customer;
11+
use Magento\Store\Model\Store;
12+
use Magento\TestFramework\Helper\Bootstrap;
13+
14+
require 'customer.php';
15+
16+
$customer = Bootstrap::getObjectManager()->create(
17+
Customer::class
18+
);
19+
$customer->setWebsiteId(1)
20+
->setEmail('[email protected]')
21+
->setPassword('password')
22+
->setGroupId(2)
23+
->setStoreId(Store::DEFAULT_STORE_ID)
24+
->setIsActive(1)
25+
->setFirstname('Firstname')
26+
->setLastname('Lastname')
27+
->setDefaultBilling(1)
28+
->setDefaultShipping(1);
29+
30+
$customer->isObjectNew(true);
31+
$customer->save();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
/**
3+
* Fixture for Customer List method.
4+
*
5+
* Copyright © Magento, Inc. All rights reserved.
6+
* See COPYING.txt for license details.
7+
*/
8+
declare(strict_types = 1);
9+
10+
use Magento\Customer\Api\CustomerRepositoryInterface;
11+
use Magento\Framework\Exception\NoSuchEntityException;
12+
use Magento\Framework\Registry;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
15+
require 'customer_rollback.php';
16+
17+
/** @var Registry $registry */
18+
$registry = Bootstrap::getObjectManager()->get(Registry::class);
19+
$registry->unregister('isSecureArea');
20+
$registry->register('isSecureArea', true);
21+
22+
/** @var CustomerRepositoryInterface $customerRepository */
23+
$customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class);
24+
try {
25+
$customer = $customerRepository->get('[email protected]');
26+
$customerRepository->delete($customer);
27+
} catch (NoSuchEntityException $e) {
28+
/** Tests which are wrapped with MySQL transaction clear all data by transaction rollback. */
29+
}
30+
31+
$registry->unregister('isSecureArea');
32+
$registry->register('isSecureArea', false);

0 commit comments

Comments
 (0)