Skip to content

Commit 4ac6aa5

Browse files
Merge branch '2.2-develop' of github.com:magento/magento2ce into MAGETWO-85050
2 parents 393dc53 + 40aaa21 commit 4ac6aa5

File tree

9 files changed

+59
-16
lines changed

9 files changed

+59
-16
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
}

dev/tests/static/testsuite/Magento/Test/Integrity/Xml/SchemaTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ public function testXmlFiles()
1414
{
1515
$invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this);
1616
$invoker(
17-
/**
18-
* @param string $filename
19-
*/
2017
function ($filename) {
2118
$dom = new \DOMDocument();
2219
$xmlFile = file_get_contents($filename);
@@ -27,9 +24,9 @@ function ($filename) {
2724

2825
$schemaLocations = [];
2926
preg_match('/xsi:noNamespaceSchemaLocation=\s*"(urn:[^"]+)"/s', $xmlFile, $schemaLocations);
30-
$this->assertEquals(
27+
$this->assertCount(
3128
2,
32-
count($schemaLocations),
29+
$schemaLocations,
3330
'The XML file at ' . $filename . ' does not have a schema properly defined. It should '
3431
. 'have a xsi:noNamespaceSchemaLocation attribute defined with a URN path. E.g. '
3532
. 'xsi:noNamespaceSchemaLocation="urn:magento:framework:Relative_Path/something.xsd"'
@@ -60,6 +57,7 @@ public function getSchemas()
6057
foreach ($componentRegistrar->getPaths(ComponentRegistrar::LIBRARY) as $libraryPath) {
6158
$libSchemas = array_merge($libSchemas, $this->_getFiles($libraryPath, '*.xsd'));
6259
}
60+
6361
return $this->_dataSet(array_merge($codeSchemas, $libSchemas));
6462
}
6563

@@ -79,6 +77,7 @@ public function getXmlFiles()
7977
foreach ($componentRegistrar->getPaths(ComponentRegistrar::LIBRARY) as $libraryPath) {
8078
$libXml = array_merge($libXml, $this->_getFiles($libraryPath, '*.xml', '/.\/Test\/./'));
8179
}
80+
8281
return $this->_dataSet(array_merge($codeXml, $designXml, $libXml));
8382
}
8483

@@ -107,8 +106,11 @@ private function _filterSpecialCases(&$files)
107106
'#conf/schema.xml$#',
108107
'#conf/solrconfig.xml$#',
109108
'#layout/swagger_index_index.xml$#',
110-
'#Doc/etc/doc/vars.xml$#'
109+
'#Doc/etc/doc/vars.xml$#',
110+
'#phpunit.xml$#',
111+
'#app/code/(?!Magento)(.*?)/.*?/Test/.*\.xml$#',
111112
];
113+
112114
foreach ($list as $pattern) {
113115
foreach ($files as $key => $value) {
114116
if (preg_match($pattern, $value)) {
@@ -124,6 +126,7 @@ protected function _dataSet($files)
124126
foreach ($files as $file) {
125127
$data[substr($file, strlen(BP))] = [$file];
126128
}
129+
127130
return $data;
128131
}
129132
}

0 commit comments

Comments
 (0)