Skip to content

Commit 1759088

Browse files
Merge pull request #594 from magento-falcons/MAGETWO-60931
Bugs - MAGETWO-60067 Advanced Pricing is very slow to import - MAGETWO-60165 Inability to Run the DI Compiler before setup - MAGETWO-48516 Most of category fields don't have Use Default Value option in Store/StoreView scope on the redesigned category page MAGETWO-60630 Wrong dependency version for magento/module-catalog MAGETWO-56675 Multiple plugins cannot be run in setup area
2 parents 5ffafe2 + 651da5a commit 1759088

File tree

13 files changed

+309
-74
lines changed

13 files changed

+309
-74
lines changed

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/Catalog/Model/Category/DataProvider.php

Lines changed: 133 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@
55
*/
66
namespace Magento\Catalog\Model\Category;
77

8+
use Magento\Catalog\Api\Data\CategoryInterface;
9+
use Magento\Catalog\Api\Data\EavAttributeInterface;
10+
use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
811
use Magento\Catalog\Model\Category;
912
use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute;
1013
use Magento\Eav\Api\Data\AttributeInterface;
1114
use Magento\Eav\Model\Config;
1215
use Magento\Eav\Model\Entity\Type;
1316
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
17+
use Magento\Framework\Stdlib\ArrayManager;
1418
use Magento\Store\Model\Store;
1519
use Magento\Store\Model\StoreManagerInterface;
1620
use Magento\Ui\Component\Form\Field;
@@ -112,6 +116,16 @@ class DataProvider extends \Magento\Ui\DataProvider\AbstractDataProvider
112116
*/
113117
private $categoryFactory;
114118

119+
/**
120+
* @var ScopeOverriddenValue
121+
*/
122+
private $scopeOverriddenValue;
123+
124+
/**
125+
* @var ArrayManager
126+
*/
127+
private $arrayManager;
128+
115129
/**
116130
* DataProvider constructor
117131
*
@@ -151,8 +165,91 @@ public function __construct(
151165
$this->storeManager = $storeManager;
152166
$this->request = $request;
153167
$this->categoryFactory = $categoryFactory;
168+
154169
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
155-
$this->meta = $this->prepareMeta($this->meta);
170+
}
171+
172+
/**
173+
* @inheritdoc
174+
*/
175+
public function getMeta()
176+
{
177+
$meta = parent::getMeta();
178+
$meta = $this->prepareMeta($meta);
179+
180+
$category = $this->getCurrentCategory();
181+
182+
if ($category) {
183+
$meta = $this->addUseDefaultValueCheckbox($category, $meta);
184+
$meta = $this->resolveParentInheritance($category, $meta);
185+
}
186+
187+
return $meta;
188+
}
189+
190+
/**
191+
* @param Category $category
192+
* @param array $meta
193+
* @return array
194+
*/
195+
private function addUseDefaultValueCheckbox(Category $category, array $meta)
196+
{
197+
/** @var EavAttributeInterface $attribute */
198+
foreach ($category->getAttributes() as $attribute) {
199+
$attributeCode = $attribute->getAttributeCode();
200+
$canDisplayUseDefault = $attribute->getScope() != EavAttributeInterface::SCOPE_GLOBAL_TEXT
201+
&& $category->getId()
202+
&& $category->getStoreId();
203+
$attributePath = $this->getArrayManager()->findPath($attributeCode, $meta);
204+
205+
if (
206+
!$attributePath
207+
|| !$canDisplayUseDefault
208+
|| in_array($attributeCode, $this->elementsWithUseConfigSetting)
209+
) {
210+
continue;
211+
}
212+
213+
$meta = $this->getArrayManager()->merge(
214+
[$attributePath, 'arguments/data/config'],
215+
$meta,
216+
[
217+
'service' => [
218+
'template' => 'ui/form/element/helper/service',
219+
],
220+
'disabled' => !$this->getScopeOverriddenValue()->containsValue(
221+
CategoryInterface::class,
222+
$category,
223+
$attributeCode,
224+
$this->request->getParam($this->requestScopeFieldName, Store::DEFAULT_STORE_ID)
225+
)
226+
]
227+
);
228+
}
229+
230+
return $meta;
231+
}
232+
233+
/**
234+
* Removes not necessary inheritance fields
235+
*
236+
* @param Category $category
237+
* @param array $meta
238+
* @return array
239+
*/
240+
private function resolveParentInheritance(Category $category, array $meta)
241+
{
242+
if (!$category->getParentId() || !$this->getArrayManager()->findPath('custom_use_parent_settings', $meta)) {
243+
return $meta;
244+
}
245+
246+
$meta = $this->getArrayManager()->merge(
247+
[$this->getArrayManager()->findPath('custom_use_parent_settings', $meta), 'arguments/data/config'],
248+
$meta,
249+
['visible' => false]
250+
);
251+
252+
return $meta;
156253
}
157254

158255
/**
@@ -204,7 +301,6 @@ public function getData()
204301
$category = $this->getCurrentCategory();
205302
if ($category) {
206303
$categoryData = $category->getData();
207-
$categoryData = $this->addUseDefaultSettings($category, $categoryData);
208304
$categoryData = $this->addUseConfigSettings($categoryData);
209305
$categoryData = $this->filterFields($categoryData);
210306
$categoryData = $this->convertValues($category, $categoryData);
@@ -292,6 +388,7 @@ protected function addUseConfigSettings($categoryData)
292388
* @param \Magento\Catalog\Model\Category $category
293389
* @param array $categoryData
294390
* @return array
391+
* @deprecated
295392
*/
296393
protected function addUseDefaultSettings($category, $categoryData)
297394
{
@@ -406,15 +503,6 @@ public function getDefaultMetaData($result)
406503
$result['use_config.available_sort_by']['default'] = true;
407504
$result['use_config.default_sort_by']['default'] = true;
408505
$result['use_config.filter_price_range']['default'] = true;
409-
if ($this->request->getParam('store') && $this->request->getParam('id')) {
410-
$result['use_default.url_key']['checked'] = true;
411-
$result['use_default.url_key']['default'] = true;
412-
$result['use_default.url_key']['visible'] = true;
413-
} else {
414-
$result['use_default.url_key']['checked'] = false;
415-
$result['use_default.url_key']['default'] = false;
416-
$result['use_default.url_key']['visible'] = false;
417-
}
418506

419507
return $result;
420508
}
@@ -454,7 +542,6 @@ protected function getFieldsMap()
454542
[
455543
'url_key',
456544
'url_key_create_redirect',
457-
'use_default.url_key',
458545
'url_key_group',
459546
'meta_title',
460547
'meta_keywords',
@@ -484,4 +571,38 @@ protected function getFieldsMap()
484571
],
485572
];
486573
}
574+
575+
/**
576+
* Retrieve scope overridden value
577+
*
578+
* @return ScopeOverriddenValue
579+
* @deprecated
580+
*/
581+
private function getScopeOverriddenValue()
582+
{
583+
if (null === $this->scopeOverriddenValue) {
584+
$this->scopeOverriddenValue = \Magento\Framework\App\ObjectManager::getInstance()->get(
585+
ScopeOverriddenValue::class
586+
);
587+
}
588+
589+
return $this->scopeOverriddenValue;
590+
}
591+
592+
/**
593+
* Retrieve array manager
594+
*
595+
* @return ArrayManager
596+
* @deprecated
597+
*/
598+
private function getArrayManager()
599+
{
600+
if (null === $this->arrayManager) {
601+
$this->arrayManager = \Magento\Framework\App\ObjectManager::getInstance()->get(
602+
ArrayManager::class
603+
);
604+
}
605+
606+
return $this->arrayManager;
607+
}
487608
}

app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,6 @@
375375
<item name="source" xsi:type="string">category</item>
376376
<item name="label" xsi:type="string" translate="true">URL Key</item>
377377
<item name="sortOrder" xsi:type="number">10</item>
378-
<item name="imports" xsi:type="array">
379-
<item name="disabled" xsi:type="string">${ $.provider }:data.use_default.url_key</item>
380-
</item>
381-
</item>
382-
</argument>
383-
</field>
384-
<field name="use_default.url_key">
385-
<argument name="data" xsi:type="array">
386-
<item name="config" xsi:type="array">
387-
<item name="description" xsi:type="string" translate="true">Use Default</item>
388-
<item name="dataType" xsi:type="string">boolean</item>
389-
<item name="formElement" xsi:type="string">checkbox</item>
390-
<item name="sortOrder" xsi:type="number">20</item>
391378
</item>
392379
</argument>
393380
</field>
@@ -453,17 +440,18 @@
453440
<field name="custom_use_parent_settings">
454441
<argument name="data" xsi:type="array">
455442
<item name="config" xsi:type="array">
456-
<item name="additionalClasses" xsi:type="string">admin__field-no-label</item>
443+
<item name="additionalClasses" xsi:type="string">admin__field-x-small</item>
457444
<item name="sortOrder" xsi:type="number">170</item>
458-
<item name="label" xsi:type="string"/>
459-
<item name="description" xsi:type="string" translate="true">Use Parent Category Settings</item>
445+
<item name="label" xsi:type="string">Use Parent Category Settings</item>
460446
<item name="dataType" xsi:type="string">boolean</item>
461447
<item name="formElement" xsi:type="string">checkbox</item>
462448
<item name="valueMap" xsi:type="array">
463449
<item name="true" xsi:type="string">1</item>
464450
<item name="false" xsi:type="string">0</item>
465451
</item>
466452
<item name="default" xsi:type="string">0</item>
453+
<item name="component" xsi:type="string">Magento_Ui/js/form/element/single-checkbox</item>
454+
<item name="prefer" xsi:type="string">toggle</item>
467455
</item>
468456
</argument>
469457
</field>
@@ -509,20 +497,21 @@
509497
<field name="custom_apply_to_products">
510498
<argument name="data" xsi:type="array">
511499
<item name="config" xsi:type="array">
512-
<item name="additionalClasses" xsi:type="string">admin__field-no-label</item>
500+
<item name="additionalClasses" xsi:type="string">admin__field-x-small</item>
513501
<item name="sortOrder" xsi:type="number">210</item>
514-
<item name="label" xsi:type="string"/>
515-
<item name="description" xsi:type="string" translate="true">Apply Design to Products</item>
502+
<item name="label" xsi:type="string" translate="true">Apply Design to Products</item>
516503
<item name="dataType" xsi:type="string">boolean</item>
517504
<item name="formElement" xsi:type="string">checkbox</item>
518-
<item name="imports" xsi:type="array">
519-
<item name="disabled" xsi:type="string">ns = ${ $.ns }, index = custom_use_parent_settings :checked</item>
520-
</item>
521505
<item name="valueMap" xsi:type="array">
522506
<item name="true" xsi:type="string">1</item>
523507
<item name="false" xsi:type="string">0</item>
524508
</item>
525509
<item name="default" xsi:type="string">0</item>
510+
<item name="component" xsi:type="string">Magento_Ui/js/form/element/single-checkbox</item>
511+
<item name="prefer" xsi:type="string">toggle</item>
512+
<item name="imports" xsi:type="array">
513+
<item name="disabled" xsi:type="string">ns = ${ $.ns }, index = custom_use_parent_settings:checked</item>
514+
</item>
526515
</item>
527516
</argument>
528517
</field>

app/code/Magento/Developer/Model/Logger/Handler/Debug.php

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Magento\Framework\App\State;
1010
use Magento\Framework\Filesystem\DriverInterface;
1111
use Magento\Store\Model\ScopeInterface;
12+
use Magento\Framework\App\DeploymentConfig;
1213

1314
/**
1415
* Class Debug
@@ -25,32 +26,44 @@ class Debug extends \Magento\Framework\Logger\Handler\Debug
2526
*/
2627
private $scopeConfig;
2728

29+
/**
30+
* @var DeploymentConfig
31+
*/
32+
private $deploymentConfig;
33+
2834
/**
2935
* @param DriverInterface $filesystem
3036
* @param State $state
3137
* @param ScopeConfigInterface $scopeConfig
38+
* @param DeploymentConfig $deploymentConfig
3239
* @param string $filePath
3340
*/
3441
public function __construct(
3542
DriverInterface $filesystem,
3643
State $state,
3744
ScopeConfigInterface $scopeConfig,
45+
DeploymentConfig $deploymentConfig,
3846
$filePath = null
3947
) {
4048
parent::__construct($filesystem, $filePath);
4149

4250
$this->state = $state;
4351
$this->scopeConfig = $scopeConfig;
52+
$this->deploymentConfig = $deploymentConfig;
4453
}
4554

4655
/**
4756
* {@inheritdoc}
4857
*/
4958
public function isHandling(array $record)
5059
{
51-
return
52-
parent::isHandling($record)
53-
&& $this->state->getMode() !== State::MODE_PRODUCTION
54-
&& $this->scopeConfig->getValue('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE);
60+
if ($this->deploymentConfig->isAvailable()) {
61+
return
62+
parent::isHandling($record)
63+
&& $this->state->getMode() !== State::MODE_PRODUCTION
64+
&& $this->scopeConfig->getValue('dev/debug/debug_logging', ScopeInterface::SCOPE_STORE);
65+
}
66+
67+
return parent::isHandling($record);
5568
}
56-
}
69+
}

0 commit comments

Comments
 (0)