Skip to content

Commit f9c4705

Browse files
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MC-18403
2 parents 0b1bf75 + 6f1a6f7 commit f9c4705

File tree

38 files changed

+916
-234
lines changed

38 files changed

+916
-234
lines changed

app/code/Magento/Bundle/Model/Product/CopyConstructor/Bundle.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
use Magento\Catalog\Model\Product;
99
use Magento\Catalog\Model\Product\Type;
1010

11+
/**
12+
* Provides duplicating bundle options and selections
13+
*/
1114
class Bundle implements \Magento\Catalog\Model\Product\CopyConstructorInterface
1215
{
1316
/**
@@ -27,7 +30,17 @@ public function build(Product $product, Product $duplicate)
2730
$bundleOptions = $product->getExtensionAttributes()->getBundleProductOptions() ?: [];
2831
$duplicatedBundleOptions = [];
2932
foreach ($bundleOptions as $key => $bundleOption) {
30-
$duplicatedBundleOptions[$key] = clone $bundleOption;
33+
$duplicatedBundleOption = clone $bundleOption;
34+
/**
35+
* Set option and selection ids to 'null' in order to create new option(selection) for duplicated product,
36+
* but not modifying existing one, which led to lost of option(selection) in original product.
37+
*/
38+
$productLinks = $duplicatedBundleOption->getProductLinks() ?: [];
39+
foreach ($productLinks as $productLink) {
40+
$productLink->setSelectionId(null);
41+
}
42+
$duplicatedBundleOption->setOptionId(null);
43+
$duplicatedBundleOptions[$key] = $duplicatedBundleOption;
3144
}
3245
$duplicate->getExtensionAttributes()->setBundleProductOptions($duplicatedBundleOptions);
3346
}

app/code/Magento/Bundle/Test/Unit/Model/Product/CopyConstructor/BundleTest.php

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Bundle\Test\Unit\Model\Product\CopyConstructor;
77

88
use Magento\Bundle\Api\Data\BundleOptionInterface;
9+
use Magento\Bundle\Model\Link;
910
use Magento\Bundle\Model\Product\CopyConstructor\Bundle;
1011
use Magento\Catalog\Api\Data\ProductExtensionInterface;
1112
use Magento\Catalog\Model\Product;
@@ -45,6 +46,7 @@ public function testBuildNegative()
4546
*/
4647
public function testBuildPositive()
4748
{
49+
/** @var Product|\PHPUnit_Framework_MockObject_MockObject $product */
4850
$product = $this->getMockBuilder(Product::class)
4951
->disableOriginalConstructor()
5052
->getMock();
@@ -60,18 +62,42 @@ public function testBuildPositive()
6062
->method('getExtensionAttributes')
6163
->willReturn($extensionAttributesProduct);
6264

65+
$productLink = $this->getMockBuilder(Link::class)
66+
->setMethods(['setSelectionId'])
67+
->disableOriginalConstructor()
68+
->getMock();
69+
$productLink->expects($this->exactly(2))
70+
->method('setSelectionId')
71+
->with($this->identicalTo(null));
72+
$firstOption = $this->getMockBuilder(BundleOptionInterface::class)
73+
->setMethods(['getProductLinks'])
74+
->disableOriginalConstructor()
75+
->getMockForAbstractClass();
76+
$firstOption->expects($this->once())
77+
->method('getProductLinks')
78+
->willReturn([$productLink]);
79+
$firstOption->expects($this->once())
80+
->method('setOptionId')
81+
->with($this->identicalTo(null));
82+
$secondOption = $this->getMockBuilder(BundleOptionInterface::class)
83+
->setMethods(['getProductLinks'])
84+
->disableOriginalConstructor()
85+
->getMockForAbstractClass();
86+
$secondOption->expects($this->once())
87+
->method('getProductLinks')
88+
->willReturn([$productLink]);
89+
$secondOption->expects($this->once())
90+
->method('setOptionId')
91+
->with($this->identicalTo(null));
6392
$bundleOptions = [
64-
$this->getMockBuilder(BundleOptionInterface::class)
65-
->disableOriginalConstructor()
66-
->getMockForAbstractClass(),
67-
$this->getMockBuilder(BundleOptionInterface::class)
68-
->disableOriginalConstructor()
69-
->getMockForAbstractClass()
93+
$firstOption,
94+
$secondOption
7095
];
7196
$extensionAttributesProduct->expects($this->once())
7297
->method('getBundleProductOptions')
7398
->willReturn($bundleOptions);
7499

100+
/** @var Product|\PHPUnit_Framework_MockObject_MockObject $duplicate */
75101
$duplicate = $this->getMockBuilder(Product::class)
76102
->disableOriginalConstructor()
77103
->getMock();

app/code/Magento/Catalog/Controller/Adminhtml/Product/Set/Edit.php

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,45 +6,63 @@
66
*/
77
namespace Magento\Catalog\Controller\Adminhtml\Product\Set;
88

9-
use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
9+
use Magento\Framework\Registry;
10+
use Magento\Backend\App\Action\Context;
11+
use Magento\Framework\App\ObjectManager;
12+
use Magento\Backend\Model\View\Result\Page;
13+
use Magento\Framework\View\Result\PageFactory;
14+
use Magento\Framework\Controller\ResultInterface;
15+
use Magento\Eav\Api\AttributeSetRepositoryInterface;
16+
use Magento\Catalog\Controller\Adminhtml\Product\Set;
17+
use Magento\Framework\Exception\NoSuchEntityException;
18+
use Magento\Framework\App\Action\HttpGetActionInterface;
1019

11-
class Edit extends \Magento\Catalog\Controller\Adminhtml\Product\Set implements HttpGetActionInterface
20+
/**
21+
* Edit attribute set controller.
22+
*/
23+
class Edit extends Set implements HttpGetActionInterface
1224
{
1325
/**
14-
* @var \Magento\Framework\View\Result\PageFactory
26+
* @var PageFactory
1527
*/
1628
protected $resultPageFactory;
1729

1830
/**
19-
* @param \Magento\Backend\App\Action\Context $context
20-
* @param \Magento\Framework\Registry $coreRegistry
21-
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
31+
* @var AttributeSetRepositoryInterface
32+
*/
33+
private $attributeSetRepository;
34+
35+
/**
36+
* @param Context $context
37+
* @param Registry $coreRegistry
38+
* @param PageFactory $resultPageFactory
39+
* @param AttributeSetRepositoryInterface $attributeSetRepository
2240
*/
2341
public function __construct(
24-
\Magento\Backend\App\Action\Context $context,
25-
\Magento\Framework\Registry $coreRegistry,
26-
\Magento\Framework\View\Result\PageFactory $resultPageFactory
42+
Context $context,
43+
Registry $coreRegistry,
44+
PageFactory $resultPageFactory,
45+
AttributeSetRepositoryInterface $attributeSetRepository = null
2746
) {
2847
parent::__construct($context, $coreRegistry);
2948
$this->resultPageFactory = $resultPageFactory;
49+
$this->attributeSetRepository = $attributeSetRepository ?:
50+
ObjectManager::getInstance()->get(AttributeSetRepositoryInterface::class);
3051
}
3152

3253
/**
33-
* @return \Magento\Backend\Model\View\Result\Page
54+
* @inheritdoc
3455
*/
3556
public function execute()
3657
{
3758
$this->_setTypeId();
38-
$attributeSet = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class)
39-
->load($this->getRequest()->getParam('id'));
40-
59+
$attributeSet = $this->attributeSetRepository->get($this->getRequest()->getParam('id'));
4160
if (!$attributeSet->getId()) {
4261
return $this->resultRedirectFactory->create()->setPath('catalog/*/index');
4362
}
44-
4563
$this->_coreRegistry->register('current_attribute_set', $attributeSet);
4664

47-
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
65+
/** @var Page $resultPage */
4866
$resultPage = $this->resultPageFactory->create();
4967
$resultPage->setActiveMenu('Magento_Catalog::catalog_attributes_sets');
5068
$resultPage->getConfig()->getTitle()->prepend(__('Attribute Sets'));

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
4747
* @SuppressWarnings(PHPMD.TooManyFields)
4848
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
49+
* @SuppressWarnings(PHPMD.ExcessiveClassLength)
4950
* @since 101.0.0
5051
*/
5152
class Eav extends AbstractModifier
@@ -1048,6 +1049,10 @@ private function isScopeGlobal($attribute)
10481049
*/
10491050
private function getAttributeModel($attribute)
10501051
{
1052+
// The statement below solves performance issue related to loading same attribute options on different models
1053+
if ($attribute instanceof EavAttribute) {
1054+
return $attribute;
1055+
}
10511056
$attributeId = $attribute->getAttributeId();
10521057

10531058
if (!array_key_exists($attributeId, $this->attributesCache)) {

app/code/Magento/Catalog/view/frontend/templates/product/list.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ $_helper = $this->helper(Magento\Catalog\Helper\Output::class);
7272
</strong>
7373
<?= $block->getReviewsSummaryHtml($_product, $templateType) ?>
7474
<?= /* @noEscape */ $block->getProductPrice($_product) ?>
75-
<?= $block->getProductDetailsHtml($_product) ?>
75+
<?php if ($_product->isAvailable()) :?>
76+
<?= $block->getProductDetailsHtml($_product) ?>
77+
<?php endif; ?>
7678

7779
<div class="product-item-inner">
7880
<div class="product actions product-item-actions"<?= strpos($pos, $viewMode . '-actions') ? $block->escapeHtmlAttr($position) : '' ?>>

app/code/Magento/CatalogGraphQl/Model/Resolver/Category/DataProvider/Breadcrumbs.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ public function __construct(
2929
}
3030

3131
/**
32+
* Get breadcrumbs data
33+
*
3234
* @param string $categoryPath
3335
* @return array
36+
* @throws \Magento\Framework\Exception\LocalizedException
3437
*/
3538
public function getData(string $categoryPath): array
3639
{
@@ -41,7 +44,7 @@ public function getData(string $categoryPath): array
4144

4245
if (count($parentCategoryIds)) {
4346
$collection = $this->collectionFactory->create();
44-
$collection->addAttributeToSelect(['name', 'url_key']);
47+
$collection->addAttributeToSelect(['name', 'url_key', 'url_path']);
4548
$collection->addAttributeToFilter('entity_id', $parentCategoryIds);
4649

4750
foreach ($collection as $category) {
@@ -50,6 +53,7 @@ public function getData(string $categoryPath): array
5053
'category_name' => $category->getName(),
5154
'category_level' => $category->getLevel(),
5255
'category_url_key' => $category->getUrlKey(),
56+
'category_url_path' => $category->getUrlPath(),
5357
];
5458
}
5559
}

app/code/Magento/CatalogGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ type Breadcrumb @doc(description: "Breadcrumb item."){
239239
category_name: String @doc(description: "Category name.")
240240
category_level: Int @doc(description: "Category level.")
241241
category_url_key: String @doc(description: "Category URL key.")
242+
category_url_path: String @doc(description: "Category URL path.")
242243
}
243244

244245
type CustomizableRadioOption implements CustomizableOptionInterface @doc(description: "CustomizableRadioOption contains information about a set of radio buttons that are defined as part of a customizable option.") {

app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@
5757
<scrollToTopOfPage stepKey="scrollToTop"/>
5858
<waitForPageLoad stepKey="waitForApplied"/>
5959
</actionGroup>
60-
60+
<actionGroup name="AdminCreateMultipleWebsiteCatalogPriceRule" extends="createCatalogPriceRule">
61+
<remove keyForRemoval="selectSite"/>
62+
<selectOption selector="{{AdminNewCatalogPriceRule.websites}}" parameterArray="['FirstWebsite', 'SecondWebsite']" stepKey="selectWebsite"/>
63+
</actionGroup>
6164
<actionGroup name="CreateCatalogPriceRuleViaTheUi">
6265
<arguments>
6366
<argument name="catalogRule" defaultValue="_defaultCatalogRule"/>

app/code/Magento/Checkout/Test/Mftf/ActionGroup/GuestCheckoutFillNewBillingAddressActionGroup.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@
2828
<fillField selector="{{CheckoutPaymentSection.guestPostcode}}" userInput="{{customerAddressVar.postcode}}" stepKey="enterPostcode"/>
2929
<fillField selector="{{CheckoutPaymentSection.guestTelephone}}" userInput="{{customerAddressVar.telephone}}" stepKey="enterTelephone"/>
3030
</actionGroup>
31+
<actionGroup name="StorefrontCheckoutFillNewBillingAddressActionGroup" extends="GuestCheckoutFillNewBillingAddressActionGroup">
32+
<remove keyForRemoval="enterEmail"/>
33+
<remove keyForRemoval="waitForLoading3"/>
34+
</actionGroup>
3135

3236
<actionGroup name="LoggedInCheckoutFillNewBillingAddressActionGroup">
3337
<annotations>

app/code/Magento/Checkout/Test/Mftf/Page/CheckoutPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
<section name="CheckoutOrderSummarySection"/>
1515
<section name="CheckoutSuccessMainSection"/>
1616
<section name="CheckoutPaymentSection"/>
17+
<section name="SelectShippingBillingPopupSection"/>
1718
</page>
1819
</pages>

0 commit comments

Comments
 (0)