Skip to content

Commit 36a2e1f

Browse files
committed
MAGETWO-72251: Backport of MAGETWO-65607 for Magento 2.1: [GitHub][PR] Check return … #10750
- Merge Pull Request #10750 from hostep/magento2:backport-pr-7794 - Merged commits: 1. ad07888
2 parents a386178 + ad07888 commit 36a2e1f

File tree

909 files changed

+137484
-47502
lines changed

Some content is hidden

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

909 files changed

+137484
-47502
lines changed

CHANGELOG.md

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

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ If you are a new GitHub user, we recommend that you create your own [free github
2929
3. Create and test your work.
3030
4. Fork the Magento 2 repository according to [Fork a repository instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#fork) and when you are ready to send us a pull request – follow [Create a pull request instructions](http://devdocs.magento.com/guides/v2.0/contributor-guide/contributing.html#pull_request).
3131
5. Once your contribution is received, Magento 2 development team will review the contribution and collaborate with you as needed to improve the quality of the contribution.
32+
33+
## Code of Conduct
34+
35+
Please note that this project is released with a Contributor Code of Conduct. We expect you to agree to its terms when participating in this project.
36+
The full text is available in the repository [Wiki](https://github.com/magento/magento2/wiki/Magento-Code-of-Conduct).

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/Backend/view/adminhtml/ui_component/design_config_form.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<item name="componentType" xsi:type="string">dynamicRows</item>
4444
<item name="recordTemplate" xsi:type="string">record</item>
4545
<item name="deleteButtonLabel" xsi:type="string">Remove</item>
46-
<item name="addButtonLabel" xsi:type="string">Add New User Agent Rule</item>
46+
<item name="addButtonLabel" xsi:type="string" translate="true">Add New User Agent Rule</item>
4747
<item name="deleteProperty" xsi:type="boolean">false</item>
4848
<item name="dndConfig" xsi:type="array">
4949
<item name="enabled" xsi:type="boolean">false</item>
@@ -67,7 +67,7 @@
6767
<item name="dataType" xsi:type="string">text</item>
6868
<item name="dataScope" xsi:type="string">search</item>
6969
<item name="fit" xsi:type="boolean">false</item>
70-
<item name="label" xsi:type="string">Search String</item>
70+
<item name="label" xsi:type="string" translate="true">Search String</item>
7171
<item name="showFallbackReset" xsi:type="boolean">false</item>
7272
</item>
7373
</argument>
@@ -80,7 +80,7 @@
8080
<item name="dataType" xsi:type="string">text</item>
8181
<item name="dataScope" xsi:type="string">value</item>
8282
<item name="fit" xsi:type="boolean">false</item>
83-
<item name="label" xsi:type="string">Theme Name</item>
83+
<item name="label" xsi:type="string" translate="true">Theme Name</item>
8484
<item name="showFallbackReset" xsi:type="boolean">false</item>
8585
</item>
8686
</argument>
@@ -91,7 +91,7 @@
9191
<item name="componentType" xsi:type="string">actionDelete</item>
9292
<item name="dataType" xsi:type="string">text</item>
9393
<item name="fit" xsi:type="boolean">false</item>
94-
<item name="label" xsi:type="string">Actions</item>
94+
<item name="label" xsi:type="string" translate="true">Actions</item>
9595
<item name="sortOrder" xsi:type="string">50</item>
9696
<item name="additionalClasses" xsi:type="string">data-grid-actions-cell</item>
9797
<item name="template" xsi:type="string">Magento_Backend/dynamic-rows/cells/action-delete</item>

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
}

0 commit comments

Comments
 (0)