Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 85ccf4b

Browse files
author
Andrey Konosov
committed
Merge commit 'refs/pull/1568/head' of github.com:magento/magento2ce into 2.2-develop
2 parents c548b09 + 3000828 commit 85ccf4b

File tree

9 files changed

+392
-104
lines changed

9 files changed

+392
-104
lines changed

app/code/Magento/Config/Block/System/Config/Form.php

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -425,24 +425,10 @@ private function getFieldData(\Magento\Config\Model\Config\Structure\Element\Fie
425425
if ($placeholderValue) {
426426
$data = $placeholderValue;
427427
}
428+
428429
if ($data === null) {
429-
if (array_key_exists($path, $this->_configData)) {
430-
$data = $this->_configData[$path];
431-
432-
if ($field->hasBackendModel()) {
433-
$backendModel = $field->getBackendModel();
434-
$backendModel->setPath($path)
435-
->setValue($data)
436-
->setWebsite($this->getWebsiteCode())
437-
->setStore($this->getStoreCode())
438-
->afterLoad();
439-
$data = $backendModel->getValue();
440-
}
441-
} elseif ($field->getConfigPath() !== null) {
442-
$data = $this->getConfigValue($field->getConfigPath());
443-
} else {
444-
$data = $this->getConfigValue($path);
445-
}
430+
$path = $field->getConfigPath() !== null ? $field->getConfigPath() : $path;
431+
$data = $this->getConfigValue($path);
446432
}
447433

448434
return $data;

app/code/Magento/Config/Model/Config/Backend/Serialized.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
*/
66
namespace Magento\Config\Model\Config\Backend;
77

8+
use Magento\Framework\App\Config\Data\ProcessorInterface;
89
use Magento\Framework\App\ObjectManager;
910
use Magento\Framework\Serialize\Serializer\Json;
1011

1112
/**
1213
* @api
1314
* @since 100.0.2
1415
*/
15-
class Serialized extends \Magento\Framework\App\Config\Value
16+
class Serialized extends \Magento\Framework\App\Config\Value implements ProcessorInterface
1617
{
1718
/**
1819
* @var Json
@@ -67,4 +68,12 @@ public function beforeSave()
6768
parent::beforeSave();
6869
return $this;
6970
}
71+
72+
/**
73+
* @inheritdoc
74+
*/
75+
public function processValue($value)
76+
{
77+
return empty($value) ? '' : $this->serializer->unserialize($value);
78+
}
7079
}

app/code/Magento/Config/Test/Unit/Block/System/Config/FormTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,12 @@ public function initFieldsDataProvider()
543543
return [
544544
[
545545
['section1/group1/field1' => 'some_value'],
546-
false,
547-
null,
546+
'some_value',
547+
'section1/group1/field1',
548548
false,
549549
'some_value',
550550
null,
551-
1,
551+
0,
552552
false,
553553
false,
554554
false

app/code/Magento/Sitemap/Model/ResourceModel/Catalog/Product.php

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,10 @@ protected function _addFilter($storeId, $attributeCode, $value, $type = '=')
192192
*
193193
* @param int $storeId
194194
* @param string $attributeCode
195+
* @param string $column Add attribute value to given column
195196
* @return void
196197
*/
197-
protected function _joinAttribute($storeId, $attributeCode)
198+
protected function _joinAttribute($storeId, $attributeCode, $column = null)
198199
{
199200
$connection = $this->getConnection();
200201
$attribute = $this->_getAttribute($attributeCode);
@@ -207,6 +208,8 @@ protected function _joinAttribute($storeId, $attributeCode)
207208
. ' AND ' . $connection->quoteInto($attrTableAlias . '.attribute_id = ?', $attribute['attribute_id']),
208209
[]
209210
);
211+
// Global scope attribute value
212+
$columnValue = 't1_' . $attributeCode . '.value';
210213

211214
if (!$attribute['is_global']) {
212215
$attrTableAlias2 = 't2_' . $attributeCode;
@@ -217,6 +220,15 @@ protected function _joinAttribute($storeId, $attributeCode)
217220
. ' AND ' . $connection->quoteInto($attrTableAlias2 . '.store_id = ?', $storeId),
218221
[]
219222
);
223+
// Store scope attribute value
224+
$columnValue = $this->getConnection()->getIfNullSql('t2_' . $attributeCode . '.value', $columnValue);
225+
}
226+
227+
// Add attribute value to result set if needed
228+
if (isset($column)) {
229+
$this->_select->columns([
230+
$column => $columnValue
231+
]);
220232
}
221233
}
222234

@@ -285,30 +297,16 @@ public function getCollection($storeId)
285297
// Join product images required attributes
286298
$imageIncludePolicy = $this->_sitemapData->getProductImageIncludePolicy($store->getId());
287299
if (\Magento\Sitemap\Model\Source\Product\Image\IncludeImage::INCLUDE_NONE != $imageIncludePolicy) {
288-
$this->_joinAttribute($store->getId(), 'name');
289-
$this->_select->columns(
290-
['name' => $this->getConnection()->getIfNullSql('t2_name.value', 't1_name.value')]
291-
);
300+
$this->_joinAttribute($store->getId(), 'name', 'name');
292301

293302
if (\Magento\Sitemap\Model\Source\Product\Image\IncludeImage::INCLUDE_ALL == $imageIncludePolicy) {
294-
$this->_joinAttribute($store->getId(), 'thumbnail');
295-
$this->_select->columns(
296-
[
297-
'thumbnail' => $this->getConnection()->getIfNullSql(
298-
't2_thumbnail.value',
299-
't1_thumbnail.value'
300-
),
301-
]
302-
);
303+
$this->_joinAttribute($store->getId(), 'thumbnail', 'thumbnail');
303304
} elseif (\Magento\Sitemap\Model\Source\Product\Image\IncludeImage::INCLUDE_BASE == $imageIncludePolicy) {
304-
$this->_joinAttribute($store->getId(), 'image');
305-
$this->_select->columns(
306-
['image' => $this->getConnection()->getIfNullSql('t2_image.value', 't1_image.value')]
307-
);
305+
$this->_joinAttribute($store->getId(), 'image', 'image');
308306
}
309307
}
310308

311-
$query = $connection->query($this->_select);
309+
$query = $connection->query($this->prepareSelectStatement($this->_select));
312310
while ($row = $query->fetch()) {
313311
$product = $this->_prepareProduct($row, $store->getId());
314312
$products[$product->getId()] = $product;
@@ -425,6 +423,17 @@ protected function _getMediaConfig()
425423
return $this->_mediaConfig;
426424
}
427425

426+
/**
427+
* Allow to modify select statement with plugins
428+
*
429+
* @param \Magento\Framework\DB\Select $select
430+
* @return \Magento\Framework\DB\Select
431+
*/
432+
public function prepareSelectStatement(\Magento\Framework\DB\Select $select)
433+
{
434+
return $select;
435+
}
436+
428437
/**
429438
* Get product image URL from image filename and path
430439
*
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Config\Block\System\Config;
8+
9+
use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
10+
11+
/**
12+
* Backend system config array field renderer for integration test.
13+
*/
14+
class FieldArray extends AbstractFieldArray
15+
{
16+
/**
17+
* @inheritdoc
18+
*/
19+
protected function _toHtml()
20+
{
21+
$value = '';
22+
$element = $this->getElement();
23+
if ($element->getValue() && is_array($element->getValue())) {
24+
$value = implode('|', $element->getValue());
25+
}
26+
27+
return sprintf(
28+
'<input id="%s" name="%s" value="%s" />',
29+
$element->getId(),
30+
$element->getName(),
31+
$value
32+
);
33+
}
34+
}

0 commit comments

Comments
 (0)