Skip to content

Commit 41b9991

Browse files
🔃 [Magento Community Engineering] Community Contributions - 2.3-develop
Accepted Community Pull Requests: - #24703: Forward port fix to keep bundle options in bundle after duplicating it (by @hostep) - #24674: Inefficient Usage of Factories (by @drpayyne) - #24694: #23880 - Fix for doubled paypal xml node (by @Yupik) - #24542: Require missing "doctrine/instantiator" dependency (by @ulftietze) - #24645: Magento_ProductAlert module. Replace replace deprecated message functions (by @atwixfirster) - #23827: Fixes #23824: User data serialised multiple times on save when loaded� (by @mustdobetter) Fixed GitHub Issues: - #13126: 2.2.2 - Duplicating Bundle Product Removes Bundle Options From Original Product (reported by @MattUnity) has been fixed in #24703 by @hostep in 2.3-develop branch Related commits: 1. f1a187e 2. bf36def 3. 629fcdf - #14112: Duplicate bundle product's child products issue. (reported by @kunj1988) has been fixed in #24703 by @hostep in 2.3-develop branch Related commits: 1. f1a187e 2. bf36def 3. 629fcdf - #23880: M2.3.2 - Node <payment><payflow_advanced><user> is declared twice in Paypal module so it still use MCrypt (reported by @Linek) has been fixed in #24694 by @Yupik in 2.3-develop branch Related commits: 1. 998cd74 2. f1e225d - #23824: User data serialised multiple times on save when loaded via loadByUsername (reported by @mustdobetter) has been fixed in #23827 by @mustdobetter in 2.3-develop branch Related commits: 1. 11f7f39 2. 6501efa 3. 41e9fff
2 parents 8441cf4 + 0adff35 commit 41b9991

File tree

13 files changed

+501
-63
lines changed

13 files changed

+501
-63
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/Paypal/etc/config.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@
164164
<title>Credit Card (Payflow Advanced)</title>
165165
<partner>PayPal</partner>
166166
<vendor>PayPal</vendor>
167-
<user>PayPal</user>
168167
<csc_required>1</csc_required>
169168
<csc_editable>1</csc_editable>
170169
<url_method>GET</url_method>

app/code/Magento/ProductAlert/Controller/Add/Price.php

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,17 @@
66

77
namespace Magento\ProductAlert\Controller\Add;
88

9-
use Magento\Framework\App\Action\HttpGetActionInterface;
10-
use Magento\ProductAlert\Controller\Add as AddController;
11-
use Magento\Framework\App\Action\Context;
12-
use Magento\Customer\Model\Session as CustomerSession;
13-
use Magento\Store\Model\StoreManagerInterface;
149
use Magento\Catalog\Api\ProductRepositoryInterface;
15-
use Magento\Framework\UrlInterface;
10+
use Magento\Customer\Model\Session as CustomerSession;
1611
use Magento\Framework\App\Action\Action;
12+
use Magento\Framework\App\Action\Context;
13+
use Magento\Framework\App\Action\HttpGetActionInterface;
1714
use Magento\Framework\Controller\ResultFactory;
15+
use Magento\Framework\Controller\Result\Redirect;
1816
use Magento\Framework\Exception\NoSuchEntityException;
17+
use Magento\Framework\UrlInterface;
18+
use Magento\ProductAlert\Controller\Add as AddController;
19+
use Magento\Store\Model\StoreManagerInterface;
1920

2021
/**
2122
* Controller for notifying about price.
@@ -28,15 +29,17 @@ class Price extends AddController implements HttpGetActionInterface
2829
protected $storeManager;
2930

3031
/**
31-
* @var \Magento\Catalog\Api\ProductRepositoryInterface
32+
* @var \Magento\Catalog\Api\ProductRepositoryInterface
3233
*/
3334
protected $productRepository;
3435

3536
/**
36-
* @param \Magento\Framework\App\Action\Context $context
37-
* @param \Magento\Customer\Model\Session $customerSession
38-
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
39-
* @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
37+
* Price constructor.
38+
*
39+
* @param Context $context
40+
* @param CustomerSession $customerSession
41+
* @param StoreManagerInterface $storeManager
42+
* @param ProductRepositoryInterface $productRepository
4043
*/
4144
public function __construct(
4245
Context $context,
@@ -54,6 +57,7 @@ public function __construct(
5457
*
5558
* @param string $url
5659
* @return bool
60+
* @throws NoSuchEntityException
5761
*/
5862
protected function isInternal($url)
5963
{
@@ -68,13 +72,14 @@ protected function isInternal($url)
6872
/**
6973
* Method for adding info about product alert price.
7074
*
71-
* @return \Magento\Framework\Controller\Result\Redirect
75+
* @return \Magento\Framework\Controller\ResultInterface
76+
* @throws NoSuchEntityException
7277
*/
7378
public function execute()
7479
{
7580
$backUrl = $this->getRequest()->getParam(Action::PARAM_NAME_URL_ENCODED);
7681
$productId = (int)$this->getRequest()->getParam('product_id');
77-
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
82+
/** @var Redirect $resultRedirect */
7883
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
7984
if (!$backUrl || !$productId) {
8085
$resultRedirect->setPath('/');
@@ -93,17 +98,17 @@ public function execute()
9398
->setWebsiteId($store->getWebsiteId())
9499
->setStoreId($store->getId());
95100
$model->save();
96-
$this->messageManager->addSuccess(__('You saved the alert subscription.'));
101+
$this->messageManager->addSuccessMessage(__('You saved the alert subscription.'));
97102
} catch (NoSuchEntityException $noEntityException) {
98-
$this->messageManager->addError(__('There are not enough parameters.'));
103+
$this->messageManager->addErrorMessage(__('There are not enough parameters.'));
99104
if ($this->isInternal($backUrl)) {
100105
$resultRedirect->setUrl($backUrl);
101106
} else {
102107
$resultRedirect->setPath('/');
103108
}
104109
return $resultRedirect;
105110
} catch (\Exception $e) {
106-
$this->messageManager->addException(
111+
$this->messageManager->addExceptionMessage(
107112
$e,
108113
__("The alert subscription couldn't update at this time. Please try again later.")
109114
);

app/code/Magento/ProductAlert/Controller/Add/Stock.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ public function execute()
7676
->setWebsiteId($store->getWebsiteId())
7777
->setStoreId($store->getId());
7878
$model->save();
79-
$this->messageManager->addSuccess(__('Alert subscription has been saved.'));
79+
$this->messageManager->addSuccessMessage(__('Alert subscription has been saved.'));
8080
} catch (NoSuchEntityException $noEntityException) {
81-
$this->messageManager->addError(__('There are not enough parameters.'));
81+
$this->messageManager->addErrorMessage(__('There are not enough parameters.'));
8282
$resultRedirect->setUrl($backUrl);
8383
return $resultRedirect;
8484
} catch (\Exception $e) {
85-
$this->messageManager->addException(
85+
$this->messageManager->addExceptionMessage(
8686
$e,
8787
__("The alert subscription couldn't update at this time. Please try again later.")
8888
);

app/code/Magento/ProductAlert/Controller/Unsubscribe/Price.php

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@
66

77
namespace Magento\ProductAlert\Controller\Unsubscribe;
88

9+
use Magento\Framework\App\Action\HttpGetActionInterface;
910
use Magento\ProductAlert\Controller\Unsubscribe as UnsubscribeController;
1011
use Magento\Framework\App\Action\Context;
1112
use Magento\Customer\Model\Session as CustomerSession;
1213
use Magento\Catalog\Api\ProductRepositoryInterface;
1314
use Magento\Framework\Controller\ResultFactory;
1415
use Magento\Framework\Exception\NoSuchEntityException;
1516

16-
class Price extends UnsubscribeController
17+
/**
18+
* Class Price
19+
*/
20+
class Price extends UnsubscribeController implements HttpGetActionInterface
1721
{
1822
/**
1923
* @var \Magento\Catalog\Api\ProductRepositoryInterface
@@ -35,6 +39,8 @@ public function __construct(
3539
}
3640

3741
/**
42+
* Unsubscribe action
43+
*
3844
* @return \Magento\Framework\Controller\Result\Redirect
3945
*/
4046
public function execute()
@@ -51,8 +57,13 @@ public function execute()
5157
/* @var $product \Magento\Catalog\Model\Product */
5258
$product = $this->productRepository->getById($productId);
5359
if (!$product->isVisibleInCatalog()) {
54-
throw new NoSuchEntityException();
60+
$this->messageManager->addErrorMessage(
61+
__("The product wasn't found. Verify the product and try again.")
62+
);
63+
$resultRedirect->setPath('customer/account/');
64+
return $resultRedirect;
5565
}
66+
5667
/** @var \Magento\ProductAlert\Model\Price $model */
5768
$model = $this->_objectManager->create(\Magento\ProductAlert\Model\Price::class)
5869
->setCustomerId($this->customerSession->getCustomerId())
@@ -67,13 +78,13 @@ public function execute()
6778
$model->delete();
6879
}
6980

70-
$this->messageManager->addSuccess(__('You deleted the alert subscription.'));
81+
$this->messageManager->addSuccessMessage(__('You deleted the alert subscription.'));
7182
} catch (NoSuchEntityException $noEntityException) {
72-
$this->messageManager->addError(__("The product wasn't found. Verify the product and try again."));
83+
$this->messageManager->addErrorMessage(__("The product wasn't found. Verify the product and try again."));
7384
$resultRedirect->setPath('customer/account/');
7485
return $resultRedirect;
7586
} catch (\Exception $e) {
76-
$this->messageManager->addException(
87+
$this->messageManager->addExceptionMessage(
7788
$e,
7889
__("The alert subscription couldn't update at this time. Please try again later.")
7990
);

app/code/Magento/ProductAlert/Controller/Unsubscribe/Stock.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ public function execute()
9494
if ($model->getId()) {
9595
$model->delete();
9696
}
97-
$this->messageManager->addSuccess(__('You will no longer receive stock alerts for this product.'));
97+
$this->messageManager->addSuccessMessage(__('You will no longer receive stock alerts for this product.'));
9898
} catch (NoSuchEntityException $noEntityException) {
99-
$this->messageManager->addError(__('The product was not found.'));
99+
$this->messageManager->addErrorMessage(__('The product was not found.'));
100100
$resultRedirect->setPath('customer/account/');
101101
return $resultRedirect;
102102
} catch (\Exception $e) {
103-
$this->messageManager->addException(
103+
$this->messageManager->addExceptionMessage(
104104
$e,
105105
__("The alert subscription couldn't update at this time. Please try again later.")
106106
);

0 commit comments

Comments
 (0)