Skip to content

Commit

Permalink
Merge pull request magento#1029 from magento-folks/develop
Browse files Browse the repository at this point in the history
Bug Fixes: MPI, Dragons, Troll, GoInc
  • Loading branch information
Olexii Korshenko committed Dec 16, 2014
2 parents 48ce78a + 4c4c034 commit cc80835
Show file tree
Hide file tree
Showing 40 changed files with 773 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public function execute()
$product = $this->productBuilder->build($this->getRequest());

$productData = $this->getRequest()->getPost('product');
if (!$productData) {
$sessionData = $this->_session->getProductData(true);
if (!empty($sessionData['product'])) {
$productData = $sessionData['product'];
}
}
if ($productData) {
$stockData = isset($productData['stock_data']) ? $productData['stock_data'] : [];
$productData['stock_data'] = $this->stockFilter->filter($stockData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ public function execute()
} catch (\Magento\Framework\Model\Exception $e) {
$this->messageManager->addError($e->getMessage());
$this->_session->setProductData($data);
$redirectBack = true;
$redirectBack = $productId ? true : 'new';
} catch (\Exception $e) {
$this->_objectManager->get('Magento\Framework\Logger')->logException($e);
$this->messageManager->addError($e->getMessage());
$redirectBack = true;
$this->_session->setProductData($data);
$redirectBack = $productId ? true : 'new';
}
}

Expand Down
51 changes: 51 additions & 0 deletions app/code/Magento/Catalog/Plugin/Model/Resource/Attribute/Save.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
*/

namespace Magento\Catalog\Plugin\Model\Resource\Attribute;

class Save
{
/**
* @var \Magento\PageCache\Model\Config
*/
protected $config;

/**
* @var \Magento\Framework\App\Cache\TypeListInterface
*/
protected $typeList;

/**
* @param \Magento\PageCache\Model\Config $config
* @param \Magento\Framework\App\Cache\TypeListInterface $typeList
*/
public function __construct(
\Magento\PageCache\Model\Config $config,
\Magento\Framework\App\Cache\TypeListInterface $typeList
) {
$this->config = $config;
$this->typeList = $typeList;
}

/**
* @param \Magento\Catalog\Model\Resource\Attribute $subject
* @param callable $proceed
* @param \Magento\Framework\Model\AbstractModel $attribute
* @return mixed
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundSave(
\Magento\Catalog\Model\Resource\Attribute $subject,
\Closure $proceed,
\Magento\Framework\Model\AbstractModel $attribute
) {
$result = $proceed($attribute);
if ($this->config->isEnabled()) {
$this->typeList->invalidate('full_page');
}
return $result;
}
}
4 changes: 3 additions & 1 deletion app/code/Magento/Catalog/etc/adminhtml/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@
</argument>
</arguments>
</type>

<type name="Magento\Catalog\Model\Indexer\Category\Product\AbstractAction">
<plugin name="invalidate_pagecache_after_rows_reindex" type="Magento\Catalog\Plugin\Model\Indexer\Category\Product\Execute" />
</type>
<type name="Magento\Catalog\Model\Resource\Attribute">
<plugin name="invalidate_cache_after_rows_reindex" type="Magento\Catalog\Plugin\Model\Resource\Attribute\Save" />
</type>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

class ChildrenCategoriesProvider
{
/** @var array */
protected $childrenIds = [];

/**
* @param \Magento\Catalog\Model\Category $category
* @param boolean $recursive
* @return \Magento\Catalog\Model\Category[]
*/
public function getChildren(Category $category, $recursive = false)
{
return $category->getResourceCollection()
return $category->isObjectNew() ? [] : $category->getResourceCollection()
->addAttributeToSelect('url_path')
->addAttributeToSelect('url_key')
->addAttributeToSelect('name')
Expand All @@ -29,16 +32,19 @@ public function getChildren(Category $category, $recursive = false)
*/
public function getChildrenIds(Category $category, $recursive = false)
{
$connection = $category->getResource()->getReadConnection();
$select = $connection->select()
->from($category->getResource()->getEntityTable(), 'entity_id')
->where($connection->quoteIdentifier('path') . ' LIKE :c_path');
$bind = ['c_path' => $category->getPath() . '/%'];
if (!$recursive) {
$select->where($connection->quoteIdentifier('level') . ' <= :c_level');
$bind['c_level'] = $category->getLevel() + 1;
$cacheKey = $category->getId() . '_' . (int)$recursive;
if (!isset($this->childrenIds[$cacheKey])) {
$connection = $category->getResource()->getReadConnection();
$select = $connection->select()
->from($category->getResource()->getEntityTable(), 'entity_id')
->where($connection->quoteIdentifier('path') . ' LIKE :c_path');
$bind = ['c_path' => $category->getPath() . '/%'];
if (!$recursive) {
$select->where($connection->quoteIdentifier('level') . ' <= :c_level');
$bind['c_level'] = $category->getLevel() + 1;
}
$this->childrenIds[$cacheKey] = $connection->fetchCol($select, $bind);
}

return $connection->fetchCol($select, $bind);
return $this->childrenIds[$cacheKey];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Magento\Catalog\Model\Category;
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
use \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider;

class Move
{
Expand All @@ -14,10 +15,14 @@ class Move

/**
* @param CategoryUrlPathGenerator $categoryUrlPathGenerator
* @param ChildrenCategoriesProvider $childrenCategoriesProvider
*/
public function __construct(CategoryUrlPathGenerator $categoryUrlPathGenerator)
{
public function __construct(
CategoryUrlPathGenerator $categoryUrlPathGenerator,
ChildrenCategoriesProvider $childrenCategoriesProvider
) {
$this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
$this->childrenCategoriesProvider = $childrenCategoriesProvider;
}

/**
Expand All @@ -37,8 +42,23 @@ public function aroundChangeParent(
$afterCategoryId
) {
$result = $proceed($category, $newParent, $afterCategoryId);
$category->setUrlKey($this->categoryUrlPathGenerator->generateUrlKey($category))
->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($category));
$category->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($category));
$category->getResource()->saveAttribute($category, 'url_path');
$this->updateUrlPathForChildren($category);

return $result;
}

/**
* @param Category $category
* @return void
*/
protected function updateUrlPathForChildren($category)
{
foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
$childCategory->unsUrlPath();
$childCategory->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($childCategory));
$childCategory->getResource()->saveAttribute($childCategory, 'url_path');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function getUrlPath($category)
return '';
}
$path = $category->getUrlPath();
if ($path !== null && !$category->dataHasChangedFor('url_key') && !$category->dataHasChangedFor('path_ids')) {
if ($path !== null && !$category->dataHasChangedFor('url_key') && !$category->dataHasChangedFor('parent_id')) {
return $path;
}
$path = $category->getUrlKey();
Expand All @@ -84,7 +84,7 @@ public function getUrlPath($category)
*/
protected function isNeedToGenerateUrlPathForParent($category)
{
return $category->getParentId() && $category->getLevel() >= self::MINIMAL_CATEGORY_LEVEL_FOR_PROCESSING;
return $category->isObjectNew() || $category->getLevel() >= self::MINIMAL_CATEGORY_LEVEL_FOR_PROCESSING;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@
use Magento\Catalog\Model\Category;
use Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator;
use Magento\Framework\Event\Observer;
use Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider;

class CategoryUrlPathAutogenerator
{
/** @var CategoryUrlPathGenerator */
protected $categoryUrlPathGenerator;

/** @var \Magento\CatalogUrlRewrite\Model\Category\ChildrenCategoriesProvider */
protected $childrenCategoriesProvider;

/**
* @param CategoryUrlPathGenerator $categoryUrlPathGenerator
* @param ChildrenCategoriesProvider $childrenCategoriesProvider
*/
public function __construct(CategoryUrlPathGenerator $categoryUrlPathGenerator)
{
public function __construct(
CategoryUrlPathGenerator $categoryUrlPathGenerator,
ChildrenCategoriesProvider $childrenCategoriesProvider
) {
$this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
$this->childrenCategoriesProvider = $childrenCategoriesProvider;
}

/**
Expand All @@ -32,6 +40,25 @@ public function invoke(Observer $observer)
if ($category->getUrlKey() !== false) {
$category->setUrlKey($this->categoryUrlPathGenerator->generateUrlKey($category))
->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($category));
if (!$category->isObjectNew()) {
$category->getResource()->saveAttribute($category, 'url_path');
if ($category->dataHasChangedFor('url_path')) {
$this->updateUrlPathForChildren($category);
}
}
}
}

/**
* @param Category $category
* @return void
*/
protected function updateUrlPathForChildren(Category $category)
{
foreach ($this->childrenCategoriesProvider->getChildren($category, true) as $childCategory) {
$childCategory->unsUrlPath();
$childCategory->setUrlPath($this->categoryUrlPathGenerator->getUrlPath($childCategory));
$childCategory->getResource()->saveAttribute($childCategory, 'url_path');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Index extends \Magento\Search\Controller\Adminhtml\Term
public function execute()
{
$resultPage = $this->createPage();
$resultPage->getPage()->getConfig()->getTitle()->prepend(__('Search Terms'));
$resultPage->getConfig()->getTitle()->prepend(__('Search Terms'));
$resultPage->addBreadcrumb(__('Search'), __('Search'));
return $resultPage;
}
Expand Down
2 changes: 2 additions & 0 deletions app/code/Magento/Tax/view/adminhtml/templates/rate/js.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ require([
], function(jQuery){

var updater = new RegionUpdater('tax_country_id', 'tax_region', 'tax_region_id', <?php echo $this->helper('Magento\Directory\Helper\Data')->getRegionJson() ?>, 'disable');
updater.disableRegionValidation();

(function ($) {
$(document).ready(function () {
'use strict';
Expand Down
14 changes: 10 additions & 4 deletions app/code/Magento/Ui/view/base/web/js/form/element/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,24 @@ define([

return Select.extend({
defaults: {
size: 5
size: 5
},

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

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

/**
* Defines if value has changed
* @return {Boolean}
* @returns {Boolean}
*/
hasChanged: function () {
var value = this.value(),
Expand All @@ -30,4 +36,4 @@ define([
return !utils.identical(value, initial);
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SanityWordsFinder extends \Magento\TestFramework\Inspection\WordsFinder
'dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Bootstrap/_files/0',
'dev/tests/unit/testsuite/Magento/_files/empty_definition_file',
'dev/tests/unit/testsuite/Magento/_files/test_definition_file',
'nginx.conf.sample',
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,13 @@ public static function suite()
{
$suite = new TestSuite('Github Publication');

// Registered checkout using PayPal Express Checkout method and offline shipping method (MAGETWO-12996)
$suite->addTestSuite('Magento\Checkout\Test\TestCase\PaypalExpress\CheckoutOnepageTest');

// New customer creation in backend (MAGETWO-12516)
$suite->addTestSuite('Magento\Customer\Test\TestCase\BackendCustomerCreateTest');

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

// Creating Refund for order paid with PayPal Express Checkout/Payflow Link/Payments Advanced/Payflow Pro/
// Payments Pro (MAGETWO-12436, MAGETWO-13061, MAGETWO-13062, MAGETWO-13063, MAGETWO-13059)
$suite->addTestSuite('Magento\Sales\Test\TestCase\OnlineRefundTest');

// Adding temporary redirect for product (MAGETWO-12409)
$suite->addTestSuite('Magento\UrlRewrite\Test\TestCase\ProductTest');

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

// Guest checkout using "Checkout with PayPal" button from product page and Free Shipping (MAGETWO-12415)
$suite->addTestSuite('Magento\Checkout\Test\TestCase\Guest\PaypalExpress\ProductPageTest');

// Creating Grouped product and assign it to the category (MAGETWO-13610)
$suite->addTestSuite('Magento\GroupedProduct\Test\TestCase\CreateGroupedTest');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testSaveActionWithDangerRequest()
$this->equalTo(['Unable to save product']),
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
);
$this->assertRedirect($this->stringContains('/backend/catalog/product/edit'));
$this->assertRedirect($this->stringContains('/backend/catalog/product/new'));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
/** @var $category \Magento\Catalog\Model\Category */
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Category');
$category->isObjectNew(true);
$category->setId(
3
)->setName(
Expand All @@ -40,6 +41,7 @@
)->save();

$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Category');
$category->isObjectNew(true);
$category->setId(
4
)->setName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
/** @var $category \Magento\Catalog\Model\Category */
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Category');
$category->isObjectNew(true);
$category->setId(
3
)->setName(
Expand All @@ -44,6 +45,7 @@
$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\Catalog\Model\Category');
$position = $index + 1;
$categoryId = $index + 4;
$category->isObjectNew(true);
$category->setId(
$categoryId
)->setName(
Expand Down
Loading

0 comments on commit cc80835

Please sign in to comment.