Skip to content

Commit 1e1eedc

Browse files
Merge branch 'develop' of https://github.corp.magento.com/magento2/magento2ce into develop
2 parents f0a0cd4 + 6054320 commit 1e1eedc

File tree

118 files changed

+1945
-1061
lines changed

Some content is hidden

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

118 files changed

+1945
-1061
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</argument>
2020
</arguments>
2121
</type>
22-
<type name="Magento\Catalog\Ui\DataProvider\Product\Form\ModifierPool">
22+
<virtualType name="Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Pool">
2323
<arguments>
2424
<argument name="modifiers" xsi:type="array">
2525
<item name="bundle" xsi:type="array">
@@ -32,7 +32,7 @@
3232
</item>
3333
</argument>
3434
</arguments>
35-
</type>
35+
</virtualType>
3636
<type name="Magento\Bundle\Ui\DataProvider\Product\Form\Modifier\Composite">
3737
<arguments>
3838
<argument name="modifiers" xsi:type="array">

app/code/Magento/BundleImportExport/Model/Import/Product/Type/Bundle.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,6 @@ public function saveData()
383383
*/
384384
public function isRowValid(array $rowData, $rowNum, $isNewProduct = true)
385385
{
386-
$rowData = array_merge($rowData, $this->transformBundleCustomAttributes($rowData));
387386
if (isset($rowData['bundle_price_type']) && $rowData['bundle_price_type'] == 'dynamic') {
388387
$rowData['price'] = isset($rowData['price']) && $rowData['price'] ? $rowData['price'] : '0.00';
389388
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Catalog\Controller\Adminhtml\Category\Image;
7+
8+
use Magento\Framework\Controller\ResultFactory;
9+
10+
/**
11+
* Class Upload
12+
*/
13+
class Upload extends \Magento\Backend\App\Action
14+
{
15+
/**
16+
* Image uploader
17+
*
18+
* @var \Magento\Catalog\Model\ImageUploader
19+
*/
20+
protected $imageUploader;
21+
22+
/**
23+
* Upload constructor.
24+
*
25+
* @param \Magento\Backend\App\Action\Context $context
26+
* @param \Magento\Catalog\Model\ImageUploader $imageUploader
27+
*/
28+
public function __construct(
29+
\Magento\Backend\App\Action\Context $context,
30+
\Magento\Catalog\Model\ImageUploader $imageUploader
31+
) {
32+
parent::__construct($context);
33+
$this->imageUploader = $imageUploader;
34+
}
35+
36+
/**
37+
* Check admin permissions for this controller
38+
*
39+
* @return boolean
40+
*/
41+
protected function _isAllowed()
42+
{
43+
return $this->_authorization->isAllowed('Magento_Catalog::categories');
44+
}
45+
46+
/**
47+
* Upload file controller action
48+
*
49+
* @return \Magento\Framework\Controller\ResultInterface
50+
*/
51+
public function execute()
52+
{
53+
try {
54+
$result = $this->imageUploader->saveFileToTmpDir('image');
55+
56+
$result['cookie'] = [
57+
'name' => $this->_getSession()->getName(),
58+
'value' => $this->_getSession()->getSessionId(),
59+
'lifetime' => $this->_getSession()->getCookieLifetime(),
60+
'path' => $this->_getSession()->getCookiePath(),
61+
'domain' => $this->_getSession()->getCookieDomain(),
62+
];
63+
} catch (\Exception $e) {
64+
$result = ['error' => $e->getMessage(), 'errorcode' => $e->getCode()];
65+
}
66+
return $this->resultFactory->create(ResultFactory::TYPE_JSON)->setData($result);
67+
}
68+
}

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
/**
99
* Class Save
10+
*
11+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1012
*/
1113
class Save extends \Magento\Catalog\Controller\Adminhtml\Category
1214
{
@@ -37,8 +39,7 @@ class Save extends \Magento\Catalog\Controller\Adminhtml\Category
3739
'include_in_menu',
3840
'is_anchor',
3941
'use_default' => ['url_key'],
40-
'use_config' => ['available_sort_by', 'filter_price_range', 'default_sort_by'],
41-
'savedImage' => ['delete']
42+
'use_config' => ['available_sort_by', 'filter_price_range', 'default_sort_by']
4243
]
4344
];
4445

@@ -171,7 +172,7 @@ public function execute()
171172
__('Attribute "%1" is required.', $attribute)
172173
);
173174
} else {
174-
throw new \Magento\Framework\Exception\LocalizedException(__($error));
175+
throw new \Exception($error);
175176
}
176177
}
177178
}
@@ -230,13 +231,9 @@ public function execute()
230231
*/
231232
public function imagePreprocessing($data)
232233
{
233-
if (!isset($_FILES) || (isset($_FILES['image']) && $_FILES['image']['name'] === '' )) {
234+
if (empty($data['general']['image'])) {
234235
unset($data['general']['image']);
235-
if (isset($data['general']['savedImage']['delete']) &&
236-
$data['general']['savedImage']['delete']
237-
) {
238-
$data['general']['image']['delete'] = $data['general']['savedImage']['delete'];
239-
}
236+
$data['general']['image']['delete'] = true;
240237
}
241238
return $data;
242239
}

app/code/Magento/Catalog/Model/AbstractModel.php

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
/**
1111
* Abstract model for catalog entities
12-
*
12+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1313
* @author Magento Core Team <core@magentocommerce.com>
1414
*/
1515
abstract class AbstractModel extends \Magento\Framework\Model\AbstractExtensibleModel
@@ -20,16 +20,16 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractExtensible
2020
* This array contain default values for attributes which was redefine
2121
* value for store
2222
*
23-
* @var array
23+
* @var array|null
2424
*/
25-
protected $_defaultValues = [];
25+
protected $_defaultValues;
2626

2727
/**
2828
* This array contains codes of attributes which have value in current store
2929
*
30-
* @var array
30+
* @var array|null
3131
*/
32-
protected $_storeValuesFlags = [];
32+
protected $_storeValuesFlags;
3333

3434
/**
3535
* Locked attributes
@@ -59,6 +59,11 @@ abstract class AbstractModel extends \Magento\Framework\Model\AbstractExtensible
5959
*/
6060
protected $_storeManager;
6161

62+
/**
63+
* @var \Magento\Catalog\Model\Attribute\ScopeOverriddenValue
64+
*/
65+
private $scopeOverriddenValue;
66+
6267
/**
6368
* @param \Magento\Framework\Model\Context $context
6469
* @param \Magento\Framework\Registry $registry
@@ -277,21 +282,49 @@ public function getWebsiteStoreIds()
277282
* @param string $attributeCode
278283
* @param mixed $value
279284
* @return $this
285+
*
286+
* @deprecated
280287
*/
281288
public function setAttributeDefaultValue($attributeCode, $value)
282289
{
283290
$this->_defaultValues[$attributeCode] = $value;
284291
return $this;
285292
}
286293

294+
/**
295+
* Get attribute scope overridden value instance
296+
*
297+
* @return \Magento\Catalog\Model\Attribute\ScopeOverriddenValue
298+
*
299+
* @deprecated
300+
*/
301+
private function getAttributeScopeOverriddenValue()
302+
{
303+
if ($this->scopeOverriddenValue === null) {
304+
$this->scopeOverriddenValue = \Magento\Framework\App\ObjectManager::getInstance()
305+
->get('Magento\Catalog\Model\Attribute\ScopeOverriddenValue');
306+
}
307+
return $this->scopeOverriddenValue;
308+
}
309+
287310
/**
288311
* Retrieve default value for attribute code
289312
*
290313
* @param string $attributeCode
291314
* @return array|boolean
315+
*
316+
* @deprecated
292317
*/
293318
public function getAttributeDefaultValue($attributeCode)
294319
{
320+
if ($this->_defaultValues === null) {
321+
$entityType = [
322+
\Magento\Catalog\Model\Product::ENTITY => \Magento\Catalog\Api\Data\ProductInterface::class,
323+
\Magento\Catalog\Model\Category::ENTITY => \Magento\Catalog\Api\Data\CategoryInterface::class,
324+
][$this->getResource()->getEntityType()->getEntityTypeCode()];
325+
$this->_defaultValues = $this->getAttributeScopeOverriddenValue()->getDefaultValues($entityType, $this);
326+
}
327+
295328
return array_key_exists($attributeCode, $this->_defaultValues) ? $this->_defaultValues[$attributeCode] : false;
296329
}
297330

@@ -301,6 +334,8 @@ public function getAttributeDefaultValue($attributeCode)
301334
*
302335
* @param string $attributeCode
303336
* @return $this
337+
*
338+
* @deprecated
304339
*/
305340
public function setExistsStoreValueFlag($attributeCode)
306341
{
@@ -314,9 +349,24 @@ public function setExistsStoreValueFlag($attributeCode)
314349
* @param string $attributeCode
315350
* @return bool
316351
* @SuppressWarnings(PHPMD.BooleanGetMethodName)
352+
*
353+
* @deprecated
317354
*/
318355
public function getExistsStoreValueFlag($attributeCode)
319356
{
357+
if ($this->_storeValuesFlags === null) {
358+
$entityType = [
359+
\Magento\Catalog\Model\Product::ENTITY => \Magento\Catalog\Api\Data\ProductInterface::class,
360+
\Magento\Catalog\Model\Category::ENTITY => \Magento\Catalog\Api\Data\CategoryInterface::class,
361+
][$this->getResource()->getEntityType()->getEntityTypeCode()];
362+
return $this->getAttributeScopeOverriddenValue()->containsValue(
363+
$entityType,
364+
$this,
365+
$attributeCode,
366+
$this->getStore()->getId()
367+
);
368+
}
369+
320370
return array_key_exists($attributeCode, $this->_storeValuesFlags);
321371
}
322372

0 commit comments

Comments
 (0)