Skip to content

Commit e5dedb8

Browse files
author
Korshenko, Olexii(okorshenko)
committed
Merge pull request #720 from magento-dragons/BugFestW2
[DRAGONS] Bug Fixes
2 parents 50d3dc1 + b1e5ae4 commit e5dedb8

File tree

17 files changed

+170
-60
lines changed

17 files changed

+170
-60
lines changed

app/code/Magento/Catalog/Block/Product/ListProduct.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public function prepareSortableFieldsByCategory($category)
296296
}
297297
$availableOrders = $this->getAvailableOrders();
298298
if (!$this->getSortBy()) {
299-
$categorySortBy = $category->getDefaultSortBy();
299+
$categorySortBy = $this->getDefaultSortBy() ?: $category->getDefaultSortBy();
300300
if ($categorySortBy) {
301301
if (!$availableOrders) {
302302
$availableOrders = $this->_getConfig()->getAttributeUsedForSortByArray();

app/code/Magento/Catalog/Block/Product/ProductList/Toolbar.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\Catalog\Block\Product\ProductList;
77

8+
use Magento\Catalog\Helper\Product\ProductList;
89
use Magento\Catalog\Model\Product\ProductList\Toolbar as ToolbarModel;
910

1011
/**
@@ -63,7 +64,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
6364
*
6465
* @var string
6566
*/
66-
protected $_direction = \Magento\Catalog\Helper\Product\ProductList::DEFAULT_SORT_DIRECTION;
67+
protected $_direction = ProductList::DEFAULT_SORT_DIRECTION;
6768

6869
/**
6970
* Default View mode
@@ -102,7 +103,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
102103
protected $_toolbarModel;
103104

104105
/**
105-
* @var \Magento\Catalog\Helper\Product\ProductList
106+
* @var ProductList
106107
*/
107108
protected $_productListHelper;
108109

@@ -122,7 +123,7 @@ class Toolbar extends \Magento\Framework\View\Element\Template
122123
* @param \Magento\Catalog\Model\Config $catalogConfig
123124
* @param ToolbarModel $toolbarModel
124125
* @param \Magento\Framework\Url\EncoderInterface $urlEncoder
125-
* @param \Magento\Catalog\Helper\Product\ProductList $productListHelper
126+
* @param ProductList $productListHelper
126127
* @param \Magento\Framework\Data\Helper\PostHelper $postDataHelper
127128
* @param array $data
128129
*/
@@ -132,7 +133,7 @@ public function __construct(
132133
\Magento\Catalog\Model\Config $catalogConfig,
133134
ToolbarModel $toolbarModel,
134135
\Magento\Framework\Url\EncoderInterface $urlEncoder,
135-
\Magento\Catalog\Helper\Product\ProductList $productListHelper,
136+
ProductList $productListHelper,
136137
\Magento\Framework\Data\Helper\PostHelper $postDataHelper,
137138
array $data = []
138139
) {
@@ -355,7 +356,7 @@ public function removeOrderFromAvailableOrders($order)
355356
}
356357

357358
/**
358-
* Compare defined order field vith current order field
359+
* Compare defined order field with current order field
359360
*
360361
* @param string $order
361362
* @return bool
@@ -375,7 +376,7 @@ public function getPagerUrl($params = [])
375376
{
376377
$urlParams = [];
377378
$urlParams['_current'] = true;
378-
$urlParams['_escape'] = true;
379+
$urlParams['_escape'] = false;
379380
$urlParams['_use_rewrite'] = true;
380381
$urlParams['_query'] = $params;
381382
return $this->getUrl('*/*/*', $urlParams);
@@ -678,7 +679,7 @@ public function getWidgetOptionsJson(array $customOptions = [])
678679
'order' => ToolbarModel::ORDER_PARAM_NAME,
679680
'limit' => ToolbarModel::LIMIT_PARAM_NAME,
680681
'modeDefault' => $defaultMode,
681-
'directionDefault' => \Magento\Catalog\Helper\Product\ProductList::DEFAULT_SORT_DIRECTION,
682+
'directionDefault' => $this->_direction ?: ProductList::DEFAULT_SORT_DIRECTION,
682683
'orderDefault' => $this->_productListHelper->getDefaultSortField(),
683684
'limitDefault' => $this->_productListHelper->getDefaultLimitPerPageValue($defaultMode),
684685
'url' => $this->getPagerUrl(),

app/code/Magento/Catalog/Setup/UpgradeData.php

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,31 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
4646
$entityTypeId = $categorySetup->getEntityTypeId(\Magento\Catalog\Model\Product::ENTITY);
4747
$attributeSetId = $categorySetup->getDefaultAttributeSetId($entityTypeId);
4848

49-
$attributeGroupId = $categorySetup->getAttributeGroupId($entityTypeId, $attributeSetId, 'Images');
50-
51-
// update General Group
52-
$categorySetup->updateAttributeGroup(
49+
$attributeGroup = $categorySetup->getAttributeGroup(
5350
$entityTypeId,
5451
$attributeSetId,
55-
$attributeGroupId,
56-
'attribute_group_name',
57-
'Images and Videos'
52+
'Images',
53+
'attribute_group_name'
5854
);
55+
if (isset($attributeGroup['attribute_group_name']) && $attributeGroup['attribute_group_name'] == 'Images') {
56+
// update General Group
57+
$categorySetup->updateAttributeGroup(
58+
$entityTypeId,
59+
$attributeSetId,
60+
$attributeGroup['attribute_group_id'],
61+
'attribute_group_name',
62+
'Images and Videos'
63+
);
64+
}
65+
}
66+
67+
if ($context->getVersion()
68+
&& version_compare($context->getVersion(), '2.0.1') < 0
69+
) {
5970
$select = $setup->getConnection()->select()
6071
->from(
6172
$setup->getTable('catalog_product_entity_group_price'),
6273
[
63-
'value_id',
6474
'entity_id',
6575
'all_groups',
6676
'customer_group_id',
@@ -69,11 +79,10 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
6979
'website_id'
7080
]
7181
);
72-
$setup->getConnection()->insertFromSelect(
82+
$select = $setup->getConnection()->insertFromSelect(
7383
$select,
74-
$setup->getTable('catalog_product_entity_group_price'),
84+
$setup->getTable('catalog_product_entity_tier_price'),
7585
[
76-
'value_id',
7786
'entity_id',
7887
'all_groups',
7988
'customer_group_id',
@@ -82,6 +91,8 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
8291
'website_id'
8392
]
8493
);
94+
$setup->getConnection()->query($select);
95+
8596
$categorySetupManager = $this->categorySetupFactory->create();
8697
$categorySetupManager->removeAttribute(\Magento\Catalog\Model\Product::ENTITY, 'group_price');
8798
}

app/code/Magento/Catalog/Setup/UpgradeSchema.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ protected function addForeignKeys(SchemaSetupInterface $setup)
140140
*/
141141
private function addSupportVideoMediaAttributes(SchemaSetupInterface $setup)
142142
{
143+
if ($setup->tableExists(Media::GALLERY_VALUE_TO_ENTITY_TABLE)) {
144+
return;
145+
};
146+
143147
/** Add support video media attribute */
144148
$this->createValueToEntityTable($setup);
145149
/**

app/code/Magento/Catalog/view/frontend/web/js/product/list/toolbar.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ define([
6868
parameters;
6969
for (var i = 0; i < urlParams.length; i++) {
7070
parameters = urlParams[i].split('=');
71-
paramData[parameters[0]] = parameters[1] !== undefined ? parameters[1] : '';
71+
paramData[parameters[0]] = parameters[1] !== undefined
72+
? window.decodeURIComponent(parameters[1].replace(/\+/g, '%20'))
73+
: '';
7274
}
7375
paramData[paramName] = paramValue;
7476
if (paramValue == defaultValue) {
@@ -81,4 +83,4 @@ define([
8183
});
8284

8385
return $.mage.productListToolbarForm;
84-
});
86+
});

app/code/Magento/CatalogSearch/Block/Result.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,13 @@ public function setListOrders()
133133
/* @var $category \Magento\Catalog\Model\Category */
134134
$availableOrders = $category->getAvailableSortByOptions();
135135
unset($availableOrders['position']);
136+
$availableOrders['relevance'] = __('Relevance');
136137

137138
$this->getListBlock()->setAvailableOrders(
138139
$availableOrders
139140
)->setDefaultDirection(
140141
'desc'
141-
)->setSortBy(
142+
)->setDefaultSortBy(
142143
'relevance'
143144
);
144145

app/code/Magento/Store/App/Request/PathInfoProcessor.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@
55
*/
66
namespace Magento\Store\App\Request;
77

8+
use Magento\Framework\Exception\NoSuchEntityException;
9+
810
class PathInfoProcessor implements \Magento\Framework\App\Request\PathInfoProcessorInterface
911
{
1012
/**
1113
* @var \Magento\Store\Model\StoreManagerInterface
1214
*/
13-
private $_storeManager;
15+
private $storeManager;
1416

1517
/**
1618
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
1719
*/
1820
public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager)
1921
{
20-
$this->_storeManager = $storeManager;
22+
$this->storeManager = $storeManager;
2123
}
2224

2325
/**
@@ -33,14 +35,15 @@ public function process(\Magento\Framework\App\RequestInterface $request, $pathI
3335
$storeCode = $pathParts[0];
3436

3537
try {
36-
$store = $this->_storeManager->getStore($storeCode);
37-
} catch (\InvalidArgumentException $e) { // TODO: MAGETWO-39826 Need to replace on NoSuchEntityException
38+
/** @var \Magento\Store\Api\Data\StoreInterface $store */
39+
$store = $this->storeManager->getStore($storeCode);
40+
} catch (NoSuchEntityException $e) {
3841
return $pathInfo;
3942
}
4043

4144
if ($store->isUseStoreInUrl()) {
4245
if (!$request->isDirectAccessFrontendName($storeCode)) {
43-
$this->_storeManager->setCurrentStore($storeCode);
46+
$this->storeManager->setCurrentStore($storeCode);
4447
$pathInfo = '/' . (isset($pathParts[1]) ? $pathParts[1] : '');
4548
return $pathInfo;
4649
} elseif (!empty($storeCode)) {

app/code/Magento/Store/Controller/Store/SwitchAction.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\Action\Action;
1010
use Magento\Framework\App\Action\Context as ActionContext;
1111
use Magento\Framework\App\Http\Context as HttpContext;
12+
use Magento\Framework\Exception\NoSuchEntityException;
1213
use Magento\Store\Api\StoreCookieManagerInterface;
1314
use Magento\Store\Api\StoreRepositoryInterface;
1415
use Magento\Store\Model\Store;
@@ -78,7 +79,7 @@ public function execute()
7879
$store = $this->storeRepository->getActiveStoreByCode($storeCode);
7980
} catch (StoreIsInactiveException $e) {
8081
$error = __('Requested store is inactive');
81-
} catch (\InvalidArgumentException $e) {
82+
} catch (NoSuchEntityException $e) {
8283
$error = __('Requested store is not found');
8384
}
8485

app/code/Magento/Store/Model/StoreRepository.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ public function get($code)
5757
$store = $this->storeFactory->create();
5858
$store->load($code, 'code');
5959
if ($store->getId() === null) {
60-
// TODO: MAGETWO-39826 Need to replace on NoSuchEntityException
61-
throw new \InvalidArgumentException();
60+
throw new NoSuchEntityException(__('Requested store is not found'));
6261
}
6362
$this->entities[$code] = $store;
6463
$this->entitiesById[$store->getId()] = $store;
@@ -89,7 +88,7 @@ public function getById($id)
8988
$store = $this->storeFactory->create();
9089
$store->load($id);
9190
if ($store->getId() === null) {
92-
throw new NoSuchEntityException();
91+
throw new NoSuchEntityException(__('Requested store is not found'));
9392
}
9493
$this->entitiesById[$id] = $store;
9594
$this->entities[$store->getCode()] = $store;

app/code/Magento/Store/Model/StoreResolver.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,9 @@ protected function getRequestedStoreByCode($storeCode)
137137
try {
138138
$store = $this->storeRepository->getActiveStoreByCode($storeCode);
139139
} catch (StoreIsInactiveException $e) {
140-
$error = __('Requested store is inactive');
141-
} catch (\InvalidArgumentException $e) { // TODO: MAGETWO-39826 Need to replace on NoSuchEntityException
142-
$error = __('Requested store is not found');
140+
throw new NoSuchEntityException(__('Requested store is inactive'));
143141
}
144142

145-
if (isset($error, $e)) {
146-
throw new NoSuchEntityException($error, $e);
147-
}
148143
return $store;
149144
}
150145

@@ -160,14 +155,9 @@ protected function getDefaultStoreById($id)
160155
try {
161156
$store = $this->storeRepository->getActiveStoreById($id);
162157
} catch (StoreIsInactiveException $e) {
163-
$error = __('Default store is inactive');
164-
} catch (\InvalidArgumentException $e) { // TODO: MAGETWO-39826 Need to replace on NoSuchEntityException
165-
$error = __('Default store is not found');
158+
throw new NoSuchEntityException(__('Default store is inactive'));
166159
}
167160

168-
if (isset($error, $e)) {
169-
throw new NoSuchEntityException($error, $e);
170-
}
171161
return $store;
172162
}
173163
}

0 commit comments

Comments
 (0)