Skip to content

Commit 35dc3fa

Browse files
committed
Merge remote-tracking branch 'mainline-ce/develop' into MAGETWO-52835
2 parents 7e93932 + bac009a commit 35dc3fa

File tree

46 files changed

+638
-140
lines changed

Some content is hidden

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

46 files changed

+638
-140
lines changed

app/code/Magento/Backend/etc/di.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
<argument name="storage" xsi:type="object">Magento\Backend\Model\Session\Quote\Storage</argument>
150150
</arguments>
151151
</type>
152-
<type name="Magento\Framework\Console\CommandList">
152+
<type name="Magento\Framework\Console\CommandListInterface">
153153
<arguments>
154154
<argument name="commands" xsi:type="array">
155155
<item name="cacheEnableCommand" xsi:type="object">Magento\Backend\Console\Command\CacheEnableCommand</item>

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ define([
180180
};
181181
});
182182

183-
$option.text(template(toTemplate));
183+
$option.html(template(toTemplate));
184184
});
185185
});
186186
},

app/code/Magento/Catalog/Model/ResourceModel/Product/Indexer/Eav/Source.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ protected function _prepareIndex($entityIds = null, $attributeId = null)
103103
* @param array $entityIds the entity ids limitation
104104
* @param int $attributeId the attribute id limitation
105105
* @return $this
106+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
106107
*/
107108
protected function _prepareSelectIndex($entityIds = null, $attributeId = null)
108109
{
@@ -125,31 +126,37 @@ protected function _prepareSelectIndex($entityIds = null, $attributeId = null)
125126
['s' => $this->getTable('store')],
126127
['store_id', 'website_id']
127128
)->joinLeft(
128-
['d' => $this->getTable('catalog_product_entity_int')],
129-
'd.store_id = 0 OR d.store_id = s.store_id',
130-
['attribute_id', 'value']
129+
['dd' => $this->getTable('catalog_product_entity_int')],
130+
'dd.store_id = 0',
131+
['attribute_id']
131132
)->joinLeft(
132-
['d2' => $this->getTable('catalog_product_entity_int')],
133+
['ds' => $this->getTable('catalog_product_entity_int')],
134+
"ds.store_id = s.store_id AND ds.attribute_id = dd.attribute_id AND " .
135+
"ds.{$productIdField} = dd.{$productIdField}",
136+
['value' => new \Zend_Db_Expr('COALESCE(ds.value, dd.value)')]
137+
)->joinLeft(
138+
['d2d' => $this->getTable('catalog_product_entity_int')],
133139
sprintf(
134-
"d.{$productIdField} = d2.{$productIdField}"
135-
. ' AND d2.attribute_id = %s AND d2.value = %s AND d.store_id = d2.store_id',
136-
$this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'status')->getId(),
137-
ProductStatus::STATUS_ENABLED
140+
"d2d.store_id = 0 AND d2d.{$productIdField} = dd.{$productIdField} AND d2d.attribute_id = %s",
141+
$this->_eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'status')->getId()
138142
),
139143
[]
144+
)->joinLeft(
145+
['d2s' => $this->getTable('catalog_product_entity_int')],
146+
"d2s.store_id = s.store_id AND d2s.attribute_id = d2d.attribute_id AND " .
147+
"d2s.{$productIdField} = d2d.{$productIdField}",
148+
[]
140149
)->joinLeft(
141150
['cpe' => $this->getTable('catalog_product_entity')],
142-
"cpe.{$productIdField} = d.{$productIdField}",
151+
"cpe.{$productIdField} = dd.{$productIdField}",
143152
array_unique([$productIdField, 'entity_id'])
144153
)->where(
145154
's.store_id != 0'
146155
)->where(
147-
'd.value IS NOT NULL'
156+
'(ds.value IS NOT NULL OR dd.value IS NOT NULL)'
148157
)->where(
149-
'd2.value IS NOT NULL'
150-
)->group([
151-
's.store_id', 's.website_id', 'cpe.entity_id', 'd.attribute_id', 'd.value',
152-
]);
158+
(new \Zend_Db_Expr('COALESCE(d2s.value, d2d.value)')) . ' = ' . ProductStatus::STATUS_ENABLED
159+
)->distinct(true);
153160

154161
if ($entityIds !== null) {
155162
$subSelect->where('cpe.entity_id IN(?)', $entityIds);

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AbstractModifier.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier;
77

88
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
9-
use Magento\Framework\Stdlib\ArrayManager;
9+
use Magento\Framework\Pricing\PriceCurrencyInterface;
1010

1111
/**
1212
* Class AbstractModifier
@@ -195,13 +195,24 @@ protected function getGroupCodeByField(array $meta, $field)
195195
}
196196

197197
/**
198-
* Format number to have only two decimals after delimiter
198+
* Format price to have only two decimals after delimiter
199199
*
200200
* @param mixed $value
201201
* @return string
202202
*/
203-
protected function formatFloat($value)
203+
protected function formatPrice($value)
204204
{
205-
return $value !== null ? number_format((float)$value, 2, '.', '') : '';
205+
return $value !== null ? number_format((float)$value, PriceCurrencyInterface::DEFAULT_PRECISION, '.', '') : '';
206+
}
207+
208+
/**
209+
* Strip excessive decimal digits from weight number
210+
*
211+
* @param mixed $value
212+
* @return string
213+
*/
214+
protected function formatWeight($value)
215+
{
216+
return (float)$value;
206217
}
207218
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/CustomOptions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ public function modifyData(array $data)
156156

157157
/** @var \Magento\Catalog\Model\Product\Option $option */
158158
foreach ($productOptions as $index => $option) {
159-
$options[$index] = $this->formatFloatByPath(static::FIELD_PRICE_NAME, $option->getData());
159+
$options[$index] = $this->formatPriceByPath(static::FIELD_PRICE_NAME, $option->getData());
160160
$values = $option->getValues() ?: [];
161161

162162
/** @var \Magento\Catalog\Model\Product\Option $value */
163163
foreach ($values as $value) {
164-
$options[$index][static::GRID_TYPE_SELECT_NAME][] = $this->formatFloatByPath(
164+
$options[$index][static::GRID_TYPE_SELECT_NAME][] = $this->formatPriceByPath(
165165
static::FIELD_PRICE_NAME,
166166
$value->getData()
167167
);
@@ -188,12 +188,12 @@ public function modifyData(array $data)
188188
* @param array $data
189189
* @return array
190190
*/
191-
protected function formatFloatByPath($path, array $data)
191+
protected function formatPriceByPath($path, array $data)
192192
{
193193
$value = $this->arrayManager->get($path, $data);
194194

195195
if (is_numeric($value)) {
196-
$data = $this->arrayManager->replace($path, $data, $this->formatFloat($value));
196+
$data = $this->arrayManager->replace($path, $data, $this->formatPrice($value));
197197
}
198198

199199
return $data;

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public function modifyData(array $data)
354354
foreach ($attributes as $attribute) {
355355
if (null !== ($attributeValue = $this->setupAttributeData($attribute))) {
356356
if ($attribute->getFrontendInput() === 'price' && is_scalar($attributeValue)) {
357-
$attributeValue = $this->formatFloat($attributeValue);
357+
$attributeValue = $this->formatPrice($attributeValue);
358358
}
359359
$data[$productId][self::DATA_SOURCE_DEFAULT][$attribute->getAttributeCode()] = $attributeValue;
360360
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __construct(
4242
*/
4343
public function modifyData(array $data)
4444
{
45-
$data = $this->customizeNumberFormat($data);
45+
$data = $this->customizeWeightFormat($data);
4646
$data = $this->customizeAdvancedPriceFormat($data);
4747
$modelId = $this->locator->getProduct()->getId();
4848

@@ -54,42 +54,29 @@ public function modifyData(array $data)
5454
}
5555

5656
/**
57-
* Customizing number fields
57+
* Customizing weight fields
5858
*
5959
* @param array $data
6060
* @return array
6161
*/
62-
protected function customizeNumberFormat(array $data)
62+
protected function customizeWeightFormat(array $data)
6363
{
6464
$model = $this->locator->getProduct();
6565
$modelId = $model->getId();
66-
$numberFields = [ProductAttributeInterface::CODE_WEIGHT];
66+
$weightFields = [ProductAttributeInterface::CODE_WEIGHT];
6767

68-
foreach ($numberFields as $fieldCode) {
68+
foreach ($weightFields as $fieldCode) {
6969
$path = $modelId . '/' . self::DATA_SOURCE_DEFAULT . '/' . $fieldCode;
70-
$number = (float)$this->arrayManager->get($path, $data);
7170
$data = $this->arrayManager->replace(
7271
$path,
7372
$data,
74-
$this->formatNumber($number)
73+
$this->formatWeight($this->arrayManager->get($path, $data))
7574
);
7675
}
7776

7877
return $data;
7978
}
8079

81-
/**
82-
* Formatting numeric field
83-
*
84-
* @param float $number
85-
* @param int $decimals
86-
* @return string
87-
*/
88-
protected function formatNumber($number, $decimals = 2)
89-
{
90-
return number_format($number, $decimals);
91-
}
92-
9380
/**
9481
* Customizing number fields for advanced price
9582
*
@@ -104,7 +91,7 @@ protected function customizeAdvancedPriceFormat(array $data)
10491
if (isset($data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode])) {
10592
foreach ($data[$modelId][self::DATA_SOURCE_DEFAULT][$fieldCode] as &$value) {
10693
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE] =
107-
$this->formatNumber($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
94+
$this->formatPrice($value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE]);
10895
$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY] =
10996
(int)$value[ProductAttributeInterface::CODE_TIER_PRICE_FIELD_PRICE_QTY];
11097
}

app/code/Magento/Catalog/etc/di.xml

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@
499499
</argument>
500500
</arguments>
501501
</type>
502-
<type name="Magento\Framework\Console\CommandList">
502+
<type name="Magento\Framework\Console\CommandListInterface">
503503
<arguments>
504504
<argument name="commands" xsi:type="array">
505505
<item name="imagesResizeCommand" xsi:type="object">Magento\Catalog\Console\Command\ImagesResizeCommand</item>
@@ -715,16 +715,63 @@
715715
</argument>
716716
</arguments>
717717
</type>
718+
<virtualType name="Magento\Catalog\EntityCreator\MetadataPool" type="Magento\Framework\EntityManager\MetadataPool">
719+
<arguments>
720+
<argument name="metadata" xsi:type="array">
721+
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="array">
722+
<item name="entityContext" xsi:type="array">
723+
<item name="store" xsi:type="string">Magento\Store\Model\DefaultStoreScopeProvider</item>
724+
</item>
725+
</item>
726+
<item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="array">
727+
<item name="entityContext" xsi:type="array">
728+
<item name="store" xsi:type="string">Magento\Store\Model\DefaultStoreScopeProvider</item>
729+
</item>
730+
</item>
731+
<item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="array">
732+
<item name="entityContext" xsi:type="array">
733+
<item name="store" xsi:type="string">Magento\Store\Model\DefaultStoreScopeProvider</item>
734+
</item>
735+
</item>
736+
</argument>
737+
</arguments>
738+
</virtualType>
739+
<virtualType name="Magento\Catalog\Model\Entity\CreationScopeResolver" type="Magento\Framework\Model\Entity\ScopeResolver">
740+
<arguments>
741+
<argument name="metadataPool" xsi:type="object">Magento\Catalog\EntityCreator\MetadataPool</argument>
742+
</arguments>
743+
</virtualType>
718744
<virtualType name="Magento\Catalog\Model\ResourceModel\CreateHandler" type="Magento\Eav\Model\ResourceModel\CreateHandler">
719745
<arguments>
720-
<argument name="attributePersistor" xsi:type="object">Magento\Catalog\Model\ResourceModel\AttributePersistor</argument>
746+
<argument name="metadataPool" xsi:type="object">Magento\Catalog\EntityCreator\MetadataPool</argument>
747+
<argument name="scopeResolver" xsi:type="object">Magento\Catalog\Model\Entity\CreationScopeResolver</argument>
721748
</arguments>
722749
</virtualType>
723750
<virtualType name="Magento\Catalog\Model\ResourceModel\UpdateHandler" type="Magento\Eav\Model\ResourceModel\UpdateHandler">
724751
<arguments>
725752
<argument name="attributePersistor" xsi:type="object">Magento\Catalog\Model\ResourceModel\AttributePersistor</argument>
726753
</arguments>
727754
</virtualType>
755+
<type name="Magento\Framework\EntityManager\Operation\AttributePool">
756+
<arguments>
757+
<argument name="extensionActions" xsi:type="array">
758+
<item name="eav" xsi:type="array">
759+
<item name="Magento\Catalog\Api\Data\CategoryTreeInterface" xsi:type="array">
760+
<item name="create" xsi:type="string">Magento\Catalog\Model\ResourceModel\CreateHandler</item>
761+
<item name="update" xsi:type="string">Magento\Catalog\Model\ResourceModel\UpdateHandler</item>
762+
</item>
763+
<item name="Magento\Catalog\Api\Data\CategoryInterface" xsi:type="array">
764+
<item name="create" xsi:type="string">Magento\Catalog\Model\ResourceModel\CreateHandler</item>
765+
<item name="update" xsi:type="string">Magento\Catalog\Model\ResourceModel\UpdateHandler</item>
766+
</item>
767+
<item name="Magento\Catalog\Api\Data\ProductInterface" xsi:type="array">
768+
<item name="create" xsi:type="string">Magento\Catalog\Model\ResourceModel\CreateHandler</item>
769+
<item name="update" xsi:type="string">Magento\Catalog\Model\ResourceModel\UpdateHandler</item>
770+
</item>
771+
</item>
772+
</argument>
773+
</arguments>
774+
</type>
728775
<type name="Magento\Framework\EntityManager\HydratorPool">
729776
<arguments>
730777
<argument name="hydrators" xsi:type="array">

app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
</argument>
2222
</arguments>
2323
<block class="Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content" as="content">
24+
<arguments>
25+
<argument name="config" xsi:type="array">
26+
<item name="parentComponent" xsi:type="string">product_form.product_form.block_gallery.block_gallery</item>
27+
</argument>
28+
</arguments>
2429
<block class="Magento\ProductVideo\Block\Adminhtml\Product\Edit\NewVideo" name="new-video"
2530
template="Magento_ProductVideo::product/edit/slideout/form.phtml"/>
2631
</block>

app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/helper/gallery.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ $formName = $block->getFormName();
1313
<div id="<?php echo $block->getHtmlId() ?>"
1414
class="gallery"
1515
data-mage-init='{"productGallery":{"template":"#<?php echo $block->getHtmlId() ?>-template"}}'
16+
data-parent-component="<?php echo $block->escapeHtml($block->getData('config/parentComponent')) ?>"
1617
data-images="<?php echo $block->escapeHtml($block->getImagesJson()) ?>"
1718
data-types="<?php echo $block->escapeHtml(
1819
$this->helper('Magento\Framework\Json\Helper\Data')->jsonEncode($block->getImageTypes())

0 commit comments

Comments
 (0)