Skip to content

Commit 36b8852

Browse files
author
Yaroslav Onischenko
committed
MAGETWO-56978: [GITHUB] Product prices not scoped to Website - scoping seems to be at store view level #5133 #7251
2 parents 2a573cc + 7047337 commit 36b8852

File tree

38 files changed

+760
-288
lines changed

38 files changed

+760
-288
lines changed

app/code/Magento/Backend/Model/View/Result/Page.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,43 +10,6 @@
1010

1111
class Page extends View\Result\Page
1212
{
13-
/**
14-
* Constructor
15-
*
16-
* @param View\Element\Template\Context $context
17-
* @param View\LayoutFactory $layoutFactory
18-
* @param View\Layout\ReaderPool $layoutReaderPool
19-
* @param Translate\InlineInterface $translateInline
20-
* @param View\Layout\BuilderFactory $layoutBuilderFactory
21-
* @param View\Layout\GeneratorPool $generatorPool
22-
* @param View\Page\Config\RendererFactory $pageConfigRendererFactory
23-
* @param View\Page\Layout\Reader $pageLayoutReader
24-
* @param string $template
25-
*/
26-
public function __construct(
27-
View\Element\Template\Context $context,
28-
View\LayoutFactory $layoutFactory,
29-
View\Layout\ReaderPool $layoutReaderPool,
30-
Translate\InlineInterface $translateInline,
31-
View\Layout\BuilderFactory $layoutBuilderFactory,
32-
View\Layout\GeneratorPool $generatorPool,
33-
View\Page\Config\RendererFactory $pageConfigRendererFactory,
34-
View\Page\Layout\Reader $pageLayoutReader,
35-
$template
36-
) {
37-
parent::__construct(
38-
$context,
39-
$layoutFactory,
40-
$layoutReaderPool,
41-
$translateInline,
42-
$layoutBuilderFactory,
43-
$generatorPool,
44-
$pageConfigRendererFactory,
45-
$pageLayoutReader,
46-
$template
47-
);
48-
}
49-
5013
/**
5114
* Define active menu item in menu block
5215
*

app/code/Magento/Catalog/Controller/Category/View.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,17 @@ public function execute()
183183
if (!$hasChildren) {
184184
// Two levels removed from parent. Need to add default page type.
185185
$parentType = strtok($type, '_');
186-
$page->addPageLayoutHandles(['type' => $parentType]);
186+
$page->addPageLayoutHandles(['type' => $parentType], null, false);
187187
}
188-
$page->addPageLayoutHandles(['type' => $type, 'id' => $category->getId()]);
188+
$page->addPageLayoutHandles(['type' => $type], null, false);
189+
$page->addPageLayoutHandles(['id' => $category->getId()]);
189190

190191
// apply custom layout update once layout is loaded
191192
$layoutUpdates = $settings->getLayoutUpdates();
192193
if ($layoutUpdates && is_array($layoutUpdates)) {
193194
foreach ($layoutUpdates as $layoutUpdate) {
194195
$page->addUpdate($layoutUpdate);
195-
$page->addPageLayoutHandles(['layout_update' => md5($layoutUpdate)]);
196+
$page->addPageLayoutHandles(['layout_update' => md5($layoutUpdate)], null, false);
196197
}
197198
}
198199

app/code/Magento/Catalog/Helper/Product/View.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,18 @@ public function initProductLayout(ResultPage $resultPage, $product, $params = nu
122122
// Load default page handles and page configurations
123123
if ($params && $params->getBeforeHandles()) {
124124
foreach ($params->getBeforeHandles() as $handle) {
125-
$resultPage->addPageLayoutHandles(
126-
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()],
127-
$handle
128-
);
125+
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku], $handle);
126+
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], $handle, false);
129127
}
130128
}
131129

132-
$resultPage->addPageLayoutHandles(
133-
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()]
134-
);
130+
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku]);
131+
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], null, false);
135132

136133
if ($params && $params->getAfterHandles()) {
137134
foreach ($params->getAfterHandles() as $handle) {
138-
$resultPage->addPageLayoutHandles(
139-
['id' => $product->getId(), 'sku' => $urlSafeSku, 'type' => $product->getTypeId()],
140-
$handle
141-
);
135+
$resultPage->addPageLayoutHandles(['id' => $product->getId(), 'sku' => $urlSafeSku], $handle);
136+
$resultPage->addPageLayoutHandles(['type' => $product->getTypeId()], $handle, false);
142137
}
143138
}
144139

app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,13 @@ protected function _loadSkuSuperDataForBunch(array $bunch)
388388
)->joinLeft(
389389
['o' => $optionTable],
390390
$this->connection->quoteIdentifier(
391-
'o.attribute_id'
391+
'm.attribute_id'
392392
) . ' = ' . $this->connection->quoteIdentifier(
393393
'o.attribute_id'
394394
),
395395
['option_id']
396396
)->where(
397-
'product_id IN ( ? )',
397+
'm.product_id IN ( ? )',
398398
$productIds
399399
);
400400

app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ protected function setUp()
183183
'fetchPairs',
184184
'joinLeft',
185185
'insertOnDuplicate',
186+
'quoteIdentifier',
186187
'delete',
187188
'quoteInto'
188189
],
@@ -519,6 +520,10 @@ public function testSaveData()
519520
[$this->productEntityLinkField => 9, 'type_id' => 'configurable', 'attr_set_code' => 'Default'],
520521
]));
521522

523+
// at(0) is select() call, quoteIdentifier() is invoked at(1) and at(2)
524+
$this->_connection->expects($this->at(1))->method('quoteIdentifier')->with('m.attribute_id')->willReturn('a');
525+
$this->_connection->expects($this->at(2))->method('quoteIdentifier')->with('o.attribute_id')->willReturn('b');
526+
522527
$this->_connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
523528
$this->_connection->expects($this->any())->method('fetchAll')->with($this->select)->will($this->returnValue([
524529
['attribute_id' => 131, 'product_id' => 1, 'option_id' => 1, 'product_super_attribute_id' => 131],

app/code/Magento/Customer/Setup/UpgradeData.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
use Magento\Framework\Setup\ModuleDataSetupInterface;
1818
use Magento\Store\Model\ScopeInterface;
1919
use Magento\Store\Model\StoreManagerInterface;
20+
use Magento\Framework\DB\FieldDataConverterFactory;
21+
use Magento\Framework\DB\DataConverter\SerializedToJson;
2022

2123
/**
2224
* @codeCoverageIgnore
@@ -51,19 +53,30 @@ class UpgradeData implements UpgradeDataInterface
5153
*/
5254
private $storeManager;
5355

56+
/**
57+
* @var FieldDataConverterFactory
58+
*/
59+
private $fieldDataConverterFactory;
60+
5461
/**
5562
* @param CustomerSetupFactory $customerSetupFactory
5663
* @param IndexerRegistry $indexerRegistry
5764
* @param \Magento\Eav\Model\Config $eavConfig
65+
* @param FieldDataConverterFactory|null $fieldDataConverterFactory
5866
*/
5967
public function __construct(
6068
CustomerSetupFactory $customerSetupFactory,
6169
IndexerRegistry $indexerRegistry,
62-
\Magento\Eav\Model\Config $eavConfig
70+
\Magento\Eav\Model\Config $eavConfig,
71+
FieldDataConverterFactory $fieldDataConverterFactory = null
6372
) {
6473
$this->customerSetupFactory = $customerSetupFactory;
6574
$this->indexerRegistry = $indexerRegistry;
6675
$this->eavConfig = $eavConfig;
76+
77+
$this->fieldDataConverterFactory = $fieldDataConverterFactory ?: ObjectManager::getInstance()->get(
78+
FieldDataConverterFactory::class
79+
);
6780
}
6881

6982
/**
@@ -132,6 +145,15 @@ public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface
132145
throw $e;
133146
}
134147
}
148+
if (version_compare($context->getVersion(), '2.0.11', '<')) {
149+
$fieldDataConverter = $this->fieldDataConverterFactory->create(SerializedToJson::class);
150+
$fieldDataConverter->convert(
151+
$setup->getConnection(),
152+
$setup->getTable('customer_eav_attribute'),
153+
'attribute_id',
154+
'validate_rules'
155+
);
156+
}
135157

136158
$indexer = $this->indexerRegistry->get(Customer::CUSTOMER_GRID_INDEXER_ID);
137159
$indexer->reindexAll();

app/code/Magento/Customer/etc/module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
9-
<module name="Magento_Customer" setup_version="2.0.10">
9+
<module name="Magento_Customer" setup_version="2.0.11">
1010
<sequence>
1111
<module name="Magento_Eav"/>
1212
<module name="Magento_Directory"/>

app/code/Magento/Eav/Model/Attribute.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function getValidateRules()
103103
if (is_array($rules)) {
104104
return $rules;
105105
} elseif (!empty($rules)) {
106-
return unserialize($rules);
106+
return $this->getSerializer()->unserialize($rules);
107107
}
108108
return [];
109109
}
@@ -119,7 +119,7 @@ public function setValidateRules($rules)
119119
if (empty($rules)) {
120120
$rules = null;
121121
} elseif (is_array($rules)) {
122-
$rules = serialize($rules);
122+
$rules = $this->getSerializer()->serialize($rules);
123123
}
124124
$this->setData('validate_rules', $rules);
125125

app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php

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

99
use Magento\Framework\Api\AttributeValueFactory;
1010
use Magento\Framework\Exception\LocalizedException;
11-
use Magento\Framework\Serialize\SerializerInterface;
11+
use Magento\Framework\Serialize\Serializer\Json;
1212

1313
/**
1414
* Entity/Attribute/Model - attribute abstract
@@ -120,9 +120,9 @@ abstract class AbstractAttribute extends \Magento\Framework\Model\AbstractExtens
120120
/**
121121
* Serializer Instance.
122122
*
123-
* @var SerializerInterface
123+
* @var Json
124124
*/
125-
private $serializer;
125+
protected $serializer;
126126

127127
/**
128128
* Array of attribute types that have empty string as a possible value.
@@ -197,12 +197,12 @@ public function __construct(
197197
* Get Serializer instance.
198198
* @deprecated
199199
*
200-
* @return SerializerInterface
200+
* @return Json
201201
*/
202-
private function getSerializer()
202+
protected function getSerializer()
203203
{
204204
if ($this->serializer === null) {
205-
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->create(SerializerInterface::class);
205+
$this->serializer = \Magento\Framework\App\ObjectManager::getInstance()->create(Json::class);
206206
}
207207

208208
return $this->serializer;

app/code/Magento/Eav/Model/ResourceModel/Attribute.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ protected function _beforeSave(AbstractModel $object)
4545
{
4646
$validateRules = $object->getData('validate_rules');
4747
if (is_array($validateRules)) {
48-
$object->setData('validate_rules', serialize($validateRules));
48+
$object->setData('validate_rules', $this->getSerializer()->serialize($validateRules));
4949
}
5050
return parent::_beforeSave($object);
5151
}

0 commit comments

Comments
 (0)