Skip to content

Commit 40aaa21

Browse files
🔃 [EngCom] Public Pull Requests - 2.2-develop
Accepted Public Pull Requests: - magento-engcom/magento2ce#967: #7720: Product Repository saves attribute values for existing product always on "Default Store Level" (by @p-bystritsky) - #13956: Use event object in 'ajax:addToCart' trigger when adding a product to the cart (by @koenner01) - #13898: Send order email for Braintree Paypal orders (by @pmclain) Fixed GitHub Issues: - #7720: Product Repository saves attribute values for existing product always on "Default Store Level" (reported by @itaymesh) has been fixed in magento-engcom/magento2ce#967 by @p-bystritsky in 2.2-develop branch Related commits: 1. a2ae375 2. 64a5161 - #12186: Custom attributes values not updated (reported by @danyvega1990) has been fixed in magento-engcom/magento2ce#967 by @p-bystritsky in 2.2-develop branch Related commits: 1. a2ae375 2. 64a5161 - #12395: Custom Magento CLI command has incorrect current store id. (reported by @Cinawork) has been fixed in magento-engcom/magento2ce#967 by @p-bystritsky in 2.2-develop branch Related commits: 1. a2ae375 2. 64a5161 - #12792: [2.1.10] No order confirmation email after paying with PayPal Express (reported by @aeu) has been fixed in #13898 by @pmclain in 2.2-develop branch Related commits: 1. 975137b 2. aec7af9 - #13778: Braintree Paypal Method No Order Confirmation Email Sent (reported by @snoroozi) has been fixed in #13898 by @pmclain in 2.2-develop branch Related commits: 1. 975137b 2. aec7af9
2 parents 3e083e8 + 6b061b7 commit 40aaa21

File tree

8 files changed

+50
-10
lines changed

8 files changed

+50
-10
lines changed

app/code/Magento/Catalog/Model/ProductRepository.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,9 @@ public function save(\Magento\Catalog\Api\Data\ProductInterface $product, $saveO
467467
if (!$ignoreLinksFlag && $ignoreLinksFlag !== null) {
468468
$productLinks = $product->getProductLinks();
469469
}
470-
$productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId();
470+
if (!isset($productDataArray['store_id'])) {
471+
$productDataArray['store_id'] = (int)$this->storeManager->getStore()->getId();
472+
}
471473
$product = $this->initializeProductData($productDataArray, empty($existingProduct));
472474

473475
$this->processLinks($product, $productLinks);

app/code/Magento/Catalog/view/frontend/web/js/catalog-add-to-cart.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ define([
9797
success: function (res) {
9898
var eventData, parameters;
9999

100-
$(document).trigger('ajax:addToCart', form.data().productSku, form, res);
100+
$(document).trigger('ajax:addToCart', {
101+
'sku': form.data().productSku,
102+
'form': form,
103+
'response': res
104+
});
101105

102106
if (self.isLoaderEnabled()) {
103107
$('body').trigger(self.options.processStop);

app/code/Magento/Quote/Observer/Webapi/SubmitObserver.php renamed to app/code/Magento/Quote/Observer/SubmitObserver.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Quote\Observer\Webapi;
6+
namespace Magento\Quote\Observer;
77

88
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
99
use Magento\Framework\Event\ObserverInterface;
@@ -13,12 +13,12 @@ class SubmitObserver implements ObserverInterface
1313
/**
1414
* @var \Psr\Log\LoggerInterface
1515
*/
16-
protected $logger;
16+
private $logger;
1717

1818
/**
1919
* @var OrderSender
2020
*/
21-
protected $orderSender;
21+
private $orderSender;
2222

2323
/**
2424
* @param \Psr\Log\LoggerInterface $logger

app/code/Magento/Quote/Test/Unit/Observer/Webapi/SubmitObserverTest.php renamed to app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
namespace Magento\Quote\Test\Unit\Observer\Webapi;
6+
namespace Magento\Quote\Test\Unit\Observer;
77

88
class SubmitObserverTest extends \PHPUnit\Framework\TestCase
99
{
1010
/**
11-
* @var \Magento\Quote\Observer\Webapi\SubmitObserver
11+
* @var \Magento\Quote\Observer\SubmitObserver
1212
*/
1313
protected $model;
1414

@@ -59,7 +59,7 @@ protected function setUp()
5959
$eventMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock);
6060
$eventMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock);
6161
$this->quoteMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
62-
$this->model = new \Magento\Quote\Observer\Webapi\SubmitObserver(
62+
$this->model = new \Magento\Quote\Observer\SubmitObserver(
6363
$this->loggerMock,
6464
$this->orderSenderMock
6565
);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
9+
<event name="sales_model_service_quote_submit_success">
10+
<observer name="sendEmail" instance="Magento\Quote\Observer\SubmitObserver" />
11+
</event>
12+
</config>

app/code/Magento/Quote/etc/webapi_rest/events.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
99
<event name="sales_model_service_quote_submit_success">
10-
<observer name="sendEmail" instance="Magento\Quote\Observer\Webapi\SubmitObserver" />
10+
<observer name="sendEmail" instance="Magento\Quote\Observer\SubmitObserver" />
1111
</event>
1212
</config>

app/code/Magento/Quote/etc/webapi_soap/events.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
99
<event name="sales_model_service_quote_submit_success">
10-
<observer name="sendEmail" instance="Magento\Quote\Observer\Webapi\SubmitObserver" />
10+
<observer name="sendEmail" instance="Magento\Quote\Observer\SubmitObserver" />
1111
</event>
1212
</config>

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
/**
1414
* Provide tests for ProductRepository model.
15+
*
16+
* @magentoDbIsolation enabled
17+
* @magentoAppIsolation enabled
1518
*/
1619
class ProductRepositoryTest extends \PHPUnit\Framework\TestCase
1720
{
@@ -122,4 +125,23 @@ public function testCreateWithoutSpecifiedType()
122125
self::assertSame('1.2300', $product->getWeight());
123126
self::assertSame('simple', $product->getTypeId());
124127
}
128+
129+
/**
130+
* Tests product repository update should use provided store code.
131+
*
132+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
133+
*/
134+
public function testProductUpdate()
135+
{
136+
$sku = 'simple';
137+
$nameUpdated = 'updated';
138+
$product = $this->productRepository->get($sku, false, 0);
139+
$product->setName($nameUpdated);
140+
$this->productRepository->save($product);
141+
$product = $this->productRepository->get($sku, false, 0);
142+
self::assertEquals(
143+
$nameUpdated,
144+
$product->getName()
145+
);
146+
}
125147
}

0 commit comments

Comments
 (0)