Skip to content

Commit b456d1d

Browse files
author
Oleksii Korshenko
committed
MAGETWO-72135: Bugfix - Multiple filter_url_params #10714
- Merge Pull Request #10714 from bardkalbakk/magento2:patch-2 - Merged commits: 1. 7a88c0b
2 parents f59024f + 7a88c0b commit b456d1d

File tree

880 files changed

+136695
-47378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

880 files changed

+136695
-47378
lines changed

CHANGELOG.md

Lines changed: 108 additions & 0 deletions
Large diffs are not rendered by default.

app/code/Magento/AdvancedPricingImportExport/Model/Import/AdvancedPricing.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,19 +542,24 @@ protected function retrieveOldSkus()
542542
*/
543543
protected function processCountExistingPrices($prices, $table)
544544
{
545+
$oldSkus = $this->retrieveOldSkus();
546+
$existProductIds = array_intersect_key($oldSkus, $prices);
547+
if (!count($existProductIds)) {
548+
return $this;
549+
}
550+
545551
$tableName = $this->_resourceFactory->create()->getTable($table);
546552
$productEntityLinkField = $this->getProductEntityLinkField();
547553
$existingPrices = $this->_connection->fetchAssoc(
548554
$this->_connection->select()->from(
549555
$tableName,
550556
['value_id', $productEntityLinkField, 'all_groups', 'customer_group_id']
551-
)
557+
)->where($productEntityLinkField . ' IN (?)', $existProductIds)
552558
);
553-
$oldSkus = $this->retrieveOldSkus();
554559
foreach ($existingPrices as $existingPrice) {
555-
foreach ($oldSkus as $sku => $productId) {
556-
if ($existingPrice[$productEntityLinkField] == $productId && isset($prices[$sku])) {
557-
$this->incrementCounterUpdated($prices[$sku], $existingPrice);
560+
foreach ($prices as $sku => $skuPrices) {
561+
if (isset($oldSkus[$sku]) && $existingPrice[$productEntityLinkField] == $oldSkus[$sku]) {
562+
$this->incrementCounterUpdated($skuPrices, $existingPrice);
558563
}
559564
}
560565
}

app/code/Magento/AdvancedPricingImportExport/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"magento/framework": "100.1.*"
1414
},
1515
"type": "magento2-module",
16-
"version": "100.1.2",
16+
"version": "100.1.3",
1717
"license": [
1818
"OSL-3.0",
1919
"AFL-3.0"

app/code/Magento/Catalog/Block/Adminhtml/Helper/Form/Wysiwyg/Content.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
use Magento\Backend\Block\Widget\Form;
1515
use Magento\Backend\Block\Widget\Form\Generic;
1616

17+
/**
18+
* Class Content
19+
*
20+
* @deprecated
21+
* @see \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav
22+
*/
1723
class Content extends Generic
1824
{
1925
/**

app/code/Magento/Catalog/Block/Product/View/Attributes.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
use Magento\Framework\Phrase;
1616
use Magento\Framework\Pricing\PriceCurrencyInterface;
1717

18+
/**
19+
* Product attributes block.
20+
*/
1821
class Attributes extends \Magento\Framework\View\Element\Template
1922
{
2023
/**
@@ -59,6 +62,7 @@ public function getProduct()
5962
if (!$this->_product) {
6063
$this->_product = $this->_coreRegistry->registry('product');
6164
}
65+
6266
return $this->_product;
6367
}
6468

@@ -96,6 +100,7 @@ public function getAdditionalData(array $excludeAttr = [])
96100
}
97101
}
98102
}
103+
99104
return $data;
100105
}
101106
}

app/code/Magento/Catalog/Controller/Adminhtml/Category.php

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ abstract class Category extends \Magento\Backend\App\Action
3131
*/
3232
protected function _initCategory($getRootInstead = false)
3333
{
34-
$categoryId = (int)$this->getRequest()->getParam('id', false);
34+
$categoryId = $this->resolveCategoryId();
3535
$storeId = (int)$this->getRequest()->getParam('store');
36-
$category = $this->_objectManager->create('Magento\Catalog\Model\Category');
36+
$category = $this->_objectManager->create(\Magento\Catalog\Model\Category::class);
3737
$category->setStoreId($storeId);
3838

3939
if ($categoryId) {
4040
$category->load($categoryId);
4141
if ($storeId) {
4242
$rootId = $this->_objectManager->get(
43-
'Magento\Store\Model\StoreManagerInterface'
43+
\Magento\Store\Model\StoreManagerInterface::class
4444
)->getStore(
4545
$storeId
4646
)->getRootCategoryId();
@@ -55,13 +55,25 @@ protected function _initCategory($getRootInstead = false)
5555
}
5656
}
5757

58-
$this->_objectManager->get('Magento\Framework\Registry')->register('category', $category);
59-
$this->_objectManager->get('Magento\Framework\Registry')->register('current_category', $category);
60-
$this->_objectManager->get('Magento\Cms\Model\Wysiwyg\Config')
58+
$this->_objectManager->get(\Magento\Framework\Registry::class)->register('category', $category);
59+
$this->_objectManager->get(\Magento\Framework\Registry::class)->register('current_category', $category);
60+
$this->_objectManager->get(\Magento\Cms\Model\Wysiwyg\Config::class)
6161
->setStoreId($this->getRequest()->getParam('store'));
6262
return $category;
6363
}
6464

65+
/**
66+
* Resolve Category Id (from get or from post).
67+
*
68+
* @return int
69+
*/
70+
private function resolveCategoryId()
71+
{
72+
$categoryId = (int)$this->getRequest()->getParam('id', false);
73+
74+
return $categoryId ?: (int)$this->getRequest()->getParam('entity_id', false);
75+
}
76+
6577
/**
6678
* Build response for ajax request
6779
*
@@ -79,7 +91,7 @@ protected function ajaxRequestResponse($category, $resultPage)
7991
if (empty($breadcrumbsPath)) {
8092
// but if no category, and it is deleted - prepare breadcrumbs from path, saved in session
8193
$breadcrumbsPath = $this->_objectManager->get(
82-
'Magento\Backend\Model\Auth\Session'
94+
\Magento\Backend\Model\Auth\Session::class
8395
)->getDeletedPath(
8496
true
8597
);
@@ -107,7 +119,7 @@ protected function ajaxRequestResponse($category, $resultPage)
107119
['response' => $eventResponse, 'controller' => $this]
108120
);
109121
/** @var \Magento\Framework\Controller\Result\Json $resultJson */
110-
$resultJson = $this->_objectManager->get('Magento\Framework\Controller\Result\Json');
122+
$resultJson = $this->_objectManager->get(\Magento\Framework\Controller\Result\Json::class);
111123
$resultJson->setHeader('Content-type', 'application/json', true);
112124
$resultJson->setData($eventResponse->getData());
113125
return $resultJson;

app/code/Magento/Catalog/Controller/Adminhtml/Category/Image/Upload.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ protected function _isAllowed()
4444
}
4545

4646
/**
47-
* Upload file controller action
47+
* Upload file controller action.
4848
*
4949
* @return \Magento\Framework\Controller\ResultInterface
5050
*/
5151
public function execute()
5252
{
53+
$imageId = $this->_request->getParam('param_name', 'image');
5354
try {
54-
$result = $this->imageUploader->saveFileToTmpDir('image');
55+
$result = $this->imageUploader->saveFileToTmpDir($imageId);
5556

5657
$result['cookie'] = [
5758
'name' => $this->_getSession()->getName(),

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

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Controller\Adminhtml\Category;
77

88
use Magento\Store\Model\StoreManagerInterface;
9+
use Magento\Catalog\Api\Data\CategoryAttributeInterface;
910

1011
/**
1112
* Class Save
@@ -48,6 +49,13 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
4849
*/
4950
private $storeManager;
5051

52+
/**
53+
* Config instance holder.
54+
*
55+
* @var \Magento\Eav\Model\Config
56+
*/
57+
private $eavConfig;
58+
5159
/**
5260
* Constructor
5361
*
@@ -72,8 +80,9 @@ public function __construct(
7280
}
7381

7482
/**
75-
* Filter category data
83+
* Filter category data.
7684
*
85+
* @deprecated
7786
* @param array $rawData
7887
* @return array
7988
*/
@@ -126,7 +135,7 @@ public function execute()
126135
$this->storeManager->setCurrentStore($store->getCode());
127136
$parentId = isset($categoryPostData['parent']) ? $categoryPostData['parent'] : null;
128137
if ($categoryPostData) {
129-
$category->addData($this->_filterCategoryPostData($categoryPostData));
138+
$category->addData($categoryPostData);
130139
if ($isNewCategory) {
131140
$parentCategory = $this->getParentCategory($parentId, $storeId);
132141
$category->setPath($parentCategory->getPath());
@@ -248,21 +257,48 @@ public function execute()
248257
}
249258

250259
/**
251-
* Image data preprocessing
260+
* Sets image attribute data to false, if image was removed.
252261
*
253262
* @param array $data
254263
*
255264
* @return array
256265
*/
257-
public function imagePreprocessing($data)
266+
public function imagePreprocessing(array $data)
258267
{
259-
if (empty($data['image'])) {
260-
unset($data['image']);
261-
$data['image']['delete'] = true;
268+
$emptyImageAttributes = $this->getEmptyImageAttributes($data);
269+
$attributeCodes = array_keys($emptyImageAttributes);
270+
foreach ($attributeCodes as $attributeCode) {
271+
$data[$attributeCode] = false;
262272
}
273+
263274
return $data;
264275
}
265276

277+
/**
278+
* Get image attributes without value.
279+
*
280+
* @param array $data
281+
* @return array
282+
*/
283+
private function getEmptyImageAttributes(array $data)
284+
{
285+
$result = [];
286+
$entityType = $this->getConfig()->getEntityType(CategoryAttributeInterface::ENTITY_TYPE_CODE);
287+
foreach ($entityType->getAttributeCollection() as $attribute) {
288+
$attributeCode = $attribute->getAttributeCode();
289+
$backendModel = $attribute->getBackend();
290+
if (isset($data[$attributeCode])) {
291+
continue;
292+
}
293+
if (!$backendModel instanceof \Magento\Catalog\Model\Category\Attribute\Backend\Image) {
294+
continue;
295+
}
296+
$result[$attributeCode] = $attribute;
297+
}
298+
299+
return $result;
300+
}
301+
266302
/**
267303
* Converting inputs from string to boolean
268304
*
@@ -346,4 +382,20 @@ protected function getRedirectParams($isNewCategory, $hasError, $categoryId, $pa
346382
}
347383
return ['path' => $path, 'params' => $params];
348384
}
385+
386+
/**
387+
* Get Config instance.
388+
*
389+
* @return \Magento\Eav\Model\Config
390+
*/
391+
private function getConfig()
392+
{
393+
if (null === $this->eavConfig) {
394+
$this->eavConfig = \Magento\Framework\App\ObjectManager::getInstance()->get(
395+
\Magento\Eav\Model\Config::class
396+
);
397+
}
398+
399+
return $this->eavConfig;
400+
}
349401
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function execute()
6868
$attributeCode = $attributeCode ?: $this->generateCode($frontendLabel[0]);
6969
$attributeId = $this->getRequest()->getParam('attribute_id');
7070
$attribute = $this->_objectManager->create(
71-
'Magento\Catalog\Model\ResourceModel\Eav\Attribute'
71+
\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class
7272
)->loadByCode(
7373
$this->_entityTypeId,
7474
$attributeCode
@@ -87,10 +87,10 @@ public function execute()
8787
if ($this->getRequest()->has('new_attribute_set_name')) {
8888
$setName = $this->getRequest()->getParam('new_attribute_set_name');
8989
/** @var $attributeSet \Magento\Eav\Model\Entity\Attribute\Set */
90-
$attributeSet = $this->_objectManager->create('Magento\Eav\Model\Entity\Attribute\Set');
90+
$attributeSet = $this->_objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class);
9191
$attributeSet->setEntityTypeId($this->_entityTypeId)->load($setName, 'attribute_set_name');
9292
if ($attributeSet->getId()) {
93-
$setName = $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($setName);
93+
$setName = $this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($setName);
9494
$this->messageManager->addError(__('An attribute set named \'%1\' already exists.', $setName));
9595

9696
$layout = $this->layoutFactory->create();
@@ -149,10 +149,16 @@ private function setMessageToResponse($response, $messages)
149149
/**
150150
* @param DataObject $response
151151
* @param array|null $options
152+
*
153+
* @return void
152154
*/
153155
private function checkUniqueOption(DataObject $response, array $options = null)
154156
{
155-
if (is_array($options) && !$this->isUniqueAdminValues($options['value'], $options['delete'])) {
157+
if (is_array($options)
158+
&& !empty($options['value'])
159+
&& !empty($options['delete'])
160+
&& !$this->isUniqueAdminValues($options['value'], $options['delete'])
161+
) {
156162
$this->setMessageToResponse($response, [__('The value of Admin must be unique.')]);
157163
$response->setError(true);
158164
}

app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ class Helper
7474
* @var \Magento\Framework\Stdlib\DateTime\Filter\DateTime
7575
*/
7676
private $dateTimeFilter;
77-
78-
/**
79-
* @var \Magento\Catalog\Model\Product\LinkTypeProvider
80-
*/
81-
private $linkTypeProvider;
8277

8378
/**
8479
* Helper constructor.
@@ -88,25 +83,21 @@ class Helper
8883
* @param ProductLinks $productLinks
8984
* @param \Magento\Backend\Helper\Js $jsHelper
9085
* @param \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
91-
* @param \Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider
9286
*/
9387
public function __construct(
9488
\Magento\Framework\App\RequestInterface $request,
9589
\Magento\Store\Model\StoreManagerInterface $storeManager,
9690
StockDataFilter $stockFilter,
9791
\Magento\Catalog\Model\Product\Initialization\Helper\ProductLinks $productLinks,
9892
\Magento\Backend\Helper\Js $jsHelper,
99-
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter,
100-
\Magento\Catalog\Model\Product\LinkTypeProvider $linkTypeProvider = null
93+
\Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter
10194
) {
10295
$this->request = $request;
10396
$this->storeManager = $storeManager;
10497
$this->stockFilter = $stockFilter;
10598
$this->productLinks = $productLinks;
10699
$this->jsHelper = $jsHelper;
107100
$this->dateFilter = $dateFilter;
108-
$this->linkTypeProvider = $linkTypeProvider ?: \Magento\Framework\App\ObjectManager::getInstance()
109-
->get(\Magento\Catalog\Model\Product\LinkTypeProvider::class);
110101
}
111102

112103
/**
@@ -256,17 +247,11 @@ protected function setProductLinks(\Magento\Catalog\Model\Product $product)
256247

257248
$product = $this->productLinks->initializeLinks($product, $links);
258249
$productLinks = $product->getProductLinks();
259-
$linkTypes = [];
260-
261-
/** @var \Magento\Catalog\Api\Data\ProductLinkTypeInterface $linkTypeObject */
262-
foreach ($this->linkTypeProvider->getItems() as $linkTypeObject) {
263-
$linkTypes[$linkTypeObject->getName()] = $product->getData($linkTypeObject->getName() . '_readonly');
264-
}
265-
266-
// skip linkTypes that were already processed on initializeLinks plugins
267-
foreach ($productLinks as $productLink) {
268-
unset($linkTypes[$productLink->getLinkType()]);
269-
}
250+
$linkTypes = [
251+
'related' => $product->getRelatedReadonly(),
252+
'upsell' => $product->getUpsellReadonly(),
253+
'crosssell' => $product->getCrosssellReadonly()
254+
];
270255

271256
foreach ($linkTypes as $linkType => $readonly) {
272257
if (isset($links[$linkType]) && !$readonly) {

0 commit comments

Comments
 (0)