Skip to content

Commit cc80835

Browse files
author
Olexii Korshenko
committed
Merge pull request magento#1029 from magento-folks/develop
Bug Fixes: MPI, Dragons, Troll, GoInc
2 parents 48ce78a + 4c4c034 commit cc80835

File tree

40 files changed

+773
-109
lines changed

40 files changed

+773
-109
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/NewAction.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public function execute()
5959
$product = $this->productBuilder->build($this->getRequest());
6060

6161
$productData = $this->getRequest()->getPost('product');
62+
if (!$productData) {
63+
$sessionData = $this->_session->getProductData(true);
64+
if (!empty($sessionData['product'])) {
65+
$productData = $sessionData['product'];
66+
}
67+
}
6268
if ($productData) {
6369
$stockData = isset($productData['stock_data']) ? $productData['stock_data'] : [];
6470
$productData['stock_data'] = $this->stockFilter->filter($stockData);

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,12 @@ public function execute()
114114
} catch (\Magento\Framework\Model\Exception $e) {
115115
$this->messageManager->addError($e->getMessage());
116116
$this->_session->setProductData($data);
117-
$redirectBack = true;
117+
$redirectBack = $productId ? true : 'new';
118118
} catch (\Exception $e) {
119119
$this->_objectManager->get('Magento\Framework\Logger')->logException($e);
120120
$this->messageManager->addError($e->getMessage());
121-
$redirectBack = true;
121+
$this->_session->setProductData($data);
122+
$redirectBack = $productId ? true : 'new';
122123
}
123124
}
124125

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
4+
*/
5+
6+
namespace Magento\Catalog\Plugin\Model\Resource\Attribute;
7+
8+
class Save
9+
{
10+
/**
11+
* @var \Magento\PageCache\Model\Config
12+
*/
13+
protected $config;
14+
15+
/**
16+
* @var \Magento\Framework\App\Cache\TypeListInterface
17+
*/
18+
protected $typeList;
19+
20+
/**
21+
* @param \Magento\PageCache\Model\Config $config
22+
* @param \Magento\Framework\App\Cache\TypeListInterface $typeList
23+
*/
24+
public function __construct(
25+
\Magento\PageCache\Model\Config $config,
26+
\Magento\Framework\App\Cache\TypeListInterface $typeList
27+
) {
28+
$this->config = $config;
29+
$this->typeList = $typeList;
30+
}
31+
32+
/**
33+
* @param \Magento\Catalog\Model\Resource\Attribute $subject
34+
* @param callable $proceed
35+
* @param \Magento\Framework\Model\AbstractModel $attribute
36+
* @return mixed
37+
*
38+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
39+
*/
40+
public function aroundSave(
41+
\Magento\Catalog\Model\Resource\Attribute $subject,
42+
\Closure $proceed,
43+
\Magento\Framework\Model\AbstractModel $attribute
44+
) {
45+
$result = $proceed($attribute);
46+
if ($this->config->isEnabled()) {
47+
$this->typeList->invalidate('full_page');
48+
}
49+
return $result;
50+
}
51+
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@
5959
</argument>
6060
</arguments>
6161
</type>
62-
6362
<type name="Magento\Catalog\Model\Indexer\Category\Product\AbstractAction">
6463
<plugin name="invalidate_pagecache_after_rows_reindex" type="Magento\Catalog\Plugin\Model\Indexer\Category\Product\Execute" />
6564
</type>
65+
<type name="Magento\Catalog\Model\Resource\Attribute">
66+
<plugin name="invalidate_cache_after_rows_reindex" type="Magento\Catalog\Plugin\Model\Resource\Attribute\Save" />
67+
</type>
6668
</config>

app/code/Magento/CatalogUrlRewrite/Model/Category/ChildrenCategoriesProvider.php

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,17 @@
88

99
class ChildrenCategoriesProvider
1010
{
11+
/** @var array */
12+
protected $childrenIds = [];
13+
1114
/**
1215
* @param \Magento\Catalog\Model\Category $category
1316
* @param boolean $recursive
1417
* @return \Magento\Catalog\Model\Category[]
1518
*/
1619
public function getChildren(Category $category, $recursive = false)
1720
{
18-
return $category->getResourceCollection()
21+
return $category->isObjectNew() ? [] : $category->getResourceCollection()
1922
->addAttributeToSelect('url_path')
2023
->addAttributeToSelect('url_key')
2124
->addAttributeToSelect('name')
@@ -29,16 +32,19 @@ public function getChildren(Category $category, $recursive = false)
2932
*/
3033
public function getChildrenIds(Category $category, $recursive = false)
3134
{
32-
$connection = $category->getResource()->getReadConnection();
33-
$select = $connection->select()
34-
->from($category->getResource()->getEntityTable(), 'entity_id')
35-
->where($connection->quoteIdentifier('path') . ' LIKE :c_path');
36-
$bind = ['c_path' => $category->getPath() . '/%'];
37-
if (!$recursive) {
38-
$select->where($connection->quoteIdentifier('level') . ' <= :c_level');
39-
$bind['c_level'] = $category->getLevel() + 1;
35+
$cacheKey = $category->getId() . '_' . (int)$recursive;
36+
if (!isset($this->childrenIds[$cacheKey])) {
37+
$connection = $category->getResource()->getReadConnection();
38+
$select = $connection->select()
39+
->from($category->getResource()->getEntityTable(), 'entity_id')
40+
->where($connection->quoteIdentifier('path') . ' LIKE :c_path');
41+
$bind = ['c_path' => $category->getPath() . '/%'];
42+
if (!$recursive) {
43+
$select->where($connection->quoteIdentifier('level') . ' <= :c_level');
44+
$bind['c_level'] = $category->getLevel() + 1;
45+
}
46+
$this->childrenIds[$cacheKey] = $connection->fetchCol($select, $bind);
4047
}
41-
42-
return $connection->fetchCol($select, $bind);
48+
return $this->childrenIds[$cacheKey];
4349
}
4450
}

app/code/Magento/CatalogUrlRewrite/Model/Category/Plugin/Category/Move.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Magento\Catalog\Model\Category;
88
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
9+
use \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider;
910

1011
class Move
1112
{
@@ -14,10 +15,14 @@ class Move
1415

1516
/**
1617
* @param CategoryUrlPathGenerator $categoryUrlPathGenerator
18+
* @param ChildrenCategoriesProvider $childrenCategoriesProvider
1719
*/
18-
public function __construct(CategoryUrlPathGenerator $categoryUrlPathGenerator)
19-
{
20+
public function __construct(
21+
CategoryUrlPathGenerator $categoryUrlPathGenerator,
22+
ChildrenCategoriesProvider $childrenCategoriesProvider
23+
) {
2024
$this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
25+
$this->childrenCategoriesProvider = $childrenCategoriesProvider;
2126
}
2227

2328
/**
@@ -37,8 +42,23 @@ public function aroundChangeParent(
3742
$afterCategoryId
3843
) {
3944
$result = $proceed($category, $newParent, $afterCategoryId);
40-
$category->setUrlKey($this->categoryUrlPathGenerator->generateUrlKey($category))
41-
->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($category));
45+
$category->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($category));
46+
$category->getResource()->saveAttribute($category, 'url_path');
47+
$this->updateUrlPathForChildren($category);
48+
4249
return $result;
4350
}
51+
52+
/**
53+
* @param Category $category
54+
* @return void
55+
*/
56+
protected function updateUrlPathForChildren($category)
57+
{
58+
foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
59+
$childCategory->unsUrlPath();
60+
$childCategory->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($childCategory));
61+
$childCategory->getResource()->saveAttribute($childCategory, 'url_path');
62+
}
63+
}
4464
}

app/code/Magento/CatalogUrlRewrite/Model/CategoryUrlPathGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function getUrlPath($category)
6464
return '';
6565
}
6666
$path = $category->getUrlPath();
67-
if ($path !== null && !$category->dataHasChangedFor('url_key') && !$category->dataHasChangedFor('path_ids')) {
67+
if ($path !== null && !$category->dataHasChangedFor('url_key') && !$category->dataHasChangedFor('parent_id')) {
6868
return $path;
6969
}
7070
$path = $category->getUrlKey();
@@ -84,7 +84,7 @@ public function getUrlPath($category)
8484
*/
8585
protected function isNeedToGenerateUrlPathForParent($category)
8686
{
87-
return $category->getParentId() && $category->getLevel() >= self::MINIMAL_CATEGORY_LEVEL_FOR_PROCESSING;
87+
return $category->isObjectNew() || $category->getLevel() >= self::MINIMAL_CATEGORY_LEVEL_FOR_PROCESSING;
8888
}
8989

9090
/**

app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogenerator.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,26 @@
77
use Magento\Catalog\Model\Category;
88
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
99
use Magento\Framework\Event\Observer;
10+
use Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider;
1011

1112
class CategoryUrlPathAutogenerator
1213
{
1314
/** @var CategoryUrlPathGenerator */
1415
protected $categoryUrlPathGenerator;
1516

17+
/** @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider */
18+
protected $childrenCategoriesProvider;
19+
1620
/**
1721
* @param CategoryUrlPathGenerator $categoryUrlPathGenerator
22+
* @param ChildrenCategoriesProvider $childrenCategoriesProvider
1823
*/
19-
public function __construct(CategoryUrlPathGenerator $categoryUrlPathGenerator)
20-
{
24+
public function __construct(
25+
CategoryUrlPathGenerator $categoryUrlPathGenerator,
26+
ChildrenCategoriesProvider $childrenCategoriesProvider
27+
) {
2128
$this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
29+
$this->childrenCategoriesProvider = $childrenCategoriesProvider;
2230
}
2331

2432
/**
@@ -32,6 +40,25 @@ public function invoke(Observer $observer)
3240
if ($category->getUrlKey() !== false) {
3341
$category->setUrlKey($this->categoryUrlPathGenerator->generateUrlKey($category))
3442
->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($category));
43+
if (!$category->isObjectNew()) {
44+
$category->getResource()->saveAttribute($category, 'url_path');
45+
if ($category->dataHasChangedFor('url_path')) {
46+
$this->updateUrlPathForChildren($category);
47+
}
48+
}
49+
}
50+
}
51+
52+
/**
53+
* @param Category $category
54+
* @return void
55+
*/
56+
protected function updateUrlPathForChildren(Category $category)
57+
{
58+
foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
59+
$childCategory->unsUrlPath();
60+
$childCategory->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($childCategory));
61+
$childCategory->getResource()->saveAttribute($childCategory, 'url_path');
3562
}
3663
}
3764
}

app/code/Magento/Search/Controller/Adminhtml/Term/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Index extends \Magento\Search\Controller\Adminhtml\Term
1313
public function execute()
1414
{
1515
$resultPage = $this->createPage();
16-
$resultPage->getPage()->getConfig()->getTitle()->prepend(__('Search Terms'));
16+
$resultPage->getConfig()->getTitle()->prepend(__('Search Terms'));
1717
$resultPage->addBreadcrumb(__('Search'), __('Search'));
1818
return $resultPage;
1919
}

app/code/Magento/Tax/view/adminhtml/templates/rate/js.phtml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ require([
1010
], function(jQuery){
1111

1212
var updater = new RegionUpdater('tax_country_id', 'tax_region', 'tax_region_id', <?php echo $this->helper('Magento\Directory\Helper\Data')->getRegionJson() ?>, 'disable');
13+
updater.disableRegionValidation();
14+
1315
(function ($) {
1416
$(document).ready(function () {
1517
'use strict';

app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,24 @@ define([
1010

1111
return Select.extend({
1212
defaults: {
13-
size: 5
13+
size: 5
1414
},
1515

16+
/**
17+
* Calls 'getInitialValue' of parent and if the result of it is not empty
18+
* string, returs it, else returnes caption or first found option's value
19+
*
20+
* @returns {Number|String}
21+
*/
1622
getInititalValue: function(){
17-
var value = __super__.getInititalValue.apply(this, arguments);
23+
var value = this._super();
1824

1925
return _.isString(value) ? value.split(',') : value;
2026
},
2127

2228
/**
2329
* Defines if value has changed
24-
* @return {Boolean}
30+
* @returns {Boolean}
2531
*/
2632
hasChanged: function () {
2733
var value = this.value(),
@@ -30,4 +36,4 @@ define([
3036
return !utils.identical(value, initial);
3137
}
3238
});
33-
});
39+
});

dev/build/publication/sanity/Magento/Tools/Sanity/SanityWordsFinder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class SanityWordsFinder extends \Magento\TestFramework\Inspection\WordsFinder
8181
'dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/_files/0',
8282
'dev/tests/unit/testsuite/Magento/_files/empty_definition_file',
8383
'dev/tests/unit/testsuite/Magento/_files/test_definition_file',
84+
'nginx.conf.sample',
8485
];
8586

8687
/**

dev/tests/functional/testsuites/Mtf/TestSuite/GithubPublicationTests.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,13 @@ public static function suite()
1919
{
2020
$suite = new TestSuite('Github Publication');
2121

22-
// Registered checkout using PayPal Express Checkout method and offline shipping method (MAGETWO-12996)
23-
$suite->addTestSuite('Magento\Checkout\Test\TestCase\PaypalExpress\CheckoutOnepageTest');
24-
2522
// New customer creation in backend (MAGETWO-12516)
2623
$suite->addTestSuite('Magento\Customer\Test\TestCase\BackendCustomerCreateTest');
2724

2825
// Using USPS/UPS/FedEx/DHL(EU)/DHL(US) online shipping carrier on checkout as a registered customer
2926
// (MAGETWO-12444, MAGETWO-12848, MAGETWO-12849, MAGETWO-12850, MAGETWO-12851)
3027
$suite->addTestSuite('Magento\Checkout\Test\TestCase\ShippingCarrierTest');
3128

32-
// Creating Refund for order paid with PayPal Express Checkout/Payflow Link/Payments Advanced/Payflow Pro/
33-
// Payments Pro (MAGETWO-12436, MAGETWO-13061, MAGETWO-13062, MAGETWO-13063, MAGETWO-13059)
34-
$suite->addTestSuite('Magento\Sales\Test\TestCase\OnlineRefundTest');
35-
3629
// Adding temporary redirect for product (MAGETWO-12409)
3730
$suite->addTestSuite('Magento\UrlRewrite\Test\TestCase\ProductTest');
3831

@@ -42,9 +35,6 @@ public static function suite()
4235
// Creating customer account (MAGETWO-12394)
4336
$suite->addTestSuite('Magento\Customer\Test\TestCase\CreateOnFrontendTest');
4437

45-
// Guest checkout using "Checkout with PayPal" button from product page and Free Shipping (MAGETWO-12415)
46-
$suite->addTestSuite('Magento\Checkout\Test\TestCase\Guest\PaypalExpress\ProductPageTest');
47-
4838
// Creating Grouped product and assign it to the category (MAGETWO-13610)
4939
$suite->addTestSuite('Magento\GroupedProduct\Test\TestCase\CreateGroupedTest');
5040

dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function testSaveActionWithDangerRequest()
1717
$this->equalTo(['Unable to save product']),
1818
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
1919
);
20-
$this->assertRedirect($this->stringContains('/backend/catalog/product/edit'));
20+
$this->assertRedirect($this->stringContains('/backend/catalog/product/new'));
2121
}
2222

2323
/**

dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/Price/_files/products_advanced.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
/** @var $category \Magento\Catalog\Model\Category */
2121
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Category');
22+
$category->isObjectNew(true);
2223
$category->setId(
2324
3
2425
)->setName(
@@ -40,6 +41,7 @@
4041
)->save();
4142

4243
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Category');
44+
$category->isObjectNew(true);
4345
$category->setId(
4446
4
4547
)->setName(

dev/tests/integration/testsuite/Magento/Catalog/Model/Layer/Filter/Price/_files/products_base.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
/** @var $category \Magento\Catalog\Model\Category */
2121
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Category');
22+
$category->isObjectNew(true);
2223
$category->setId(
2324
3
2425
)->setName(
@@ -44,6 +45,7 @@
4445
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Category');
4546
$position = $index + 1;
4647
$categoryId = $index + 4;
48+
$category->isObjectNew(true);
4749
$category->setId(
4850
$categoryId
4951
)->setName(

0 commit comments

Comments
 (0)