Skip to content

Commit c6a14bb

Browse files
author
Ivan Gavryshko
committed
MAGETWO-52448: [Cloud] Customer address is displayed incorrectly
- fixed
1 parent fc32492 commit c6a14bb

File tree

4 files changed

+52
-2
lines changed

4 files changed

+52
-2
lines changed

app/code/Magento/Catalog/Setup/CategorySetup.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ class CategorySetup extends EavSetup
2424
*/
2525
private $categoryFactory;
2626

27+
/**
28+
* This should be set explicitly
29+
*/
30+
const CATEGORY_ENTITY_TYPE_ID = 3;
31+
32+
/**
33+
* This should be set explicitly
34+
*/
35+
const CATALOG_PRODUCT_ENTITY_TYPE_ID = 4;
36+
2737
/**
2838
* Init
2939
*
@@ -66,6 +76,7 @@ public function getDefaultEntities()
6676
{
6777
return [
6878
'catalog_category' => [
79+
'entity_type_id' => self::CATEGORY_ENTITY_TYPE_ID,
6980
'entity_model' => 'Magento\Catalog\Model\ResourceModel\Category',
7081
'attribute_model' => 'Magento\Catalog\Model\ResourceModel\Eav\Attribute',
7182
'table' => 'catalog_category_entity',
@@ -334,6 +345,7 @@ public function getDefaultEntities()
334345
],
335346
],
336347
'catalog_product' => [
348+
'entity_type_id' => self::CATALOG_PRODUCT_ENTITY_TYPE_ID,
337349
'entity_model' => 'Magento\Catalog\Model\ResourceModel\Product',
338350
'attribute_model' => 'Magento\Catalog\Model\ResourceModel\Eav\Attribute',
339351
'table' => 'catalog_product_entity',

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ public function getDefaultEntities()
126126
{
127127
$entities = [
128128
'customer' => [
129+
'entity_type_id' => \Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER,
129130
'entity_model' => 'Magento\Customer\Model\ResourceModel\Customer',
130131
'attribute_model' => 'Magento\Customer\Model\Attribute',
131132
'table' => 'customer_entity',
@@ -338,6 +339,7 @@ public function getDefaultEntities()
338339
],
339340
],
340341
'customer_address' => [
342+
'entity_type_id' => \Magento\Customer\Api\AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS,
341343
'entity_model' => 'Magento\Customer\Model\ResourceModel\Address',
342344
'attribute_model' => 'Magento\Customer\Model\Attribute',
343345
'table' => 'customer_address_entity',

app/code/Magento/Eav/Setup/EavSetup.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,21 @@ public function addEntityType($code, array $params)
192192
'additional_attribute_table' => $this->_getValue($params, 'additional_attribute_table'),
193193
'entity_attribute_collection' => $this->_getValue($params, 'entity_attribute_collection'),
194194
];
195+
if (isset($params['entity_type_id'])) {
196+
$data['entity_type_id'] = $params['entity_type_id'];
197+
}
195198

196199
if ($this->getEntityType($code, 'entity_type_id')) {
197200
$this->updateEntityType($code, $data);
198201
} else {
199202
$this->setup->getConnection()->insert($this->setup->getTable('eav_entity_type'), $data);
200203
}
201204

202-
$this->addAttributeSet($code, $this->_defaultAttributeSetName);
205+
if (isset($params['entity_type_id'])) {
206+
$this->addAttributeSet($code, $this->_defaultAttributeSetName, null, $params['entity_type_id']);
207+
} else {
208+
$this->addAttributeSet($code, $this->_defaultAttributeSetName);
209+
}
203210
$this->addAttributeGroup($code, $this->_defaultGroupName, $this->_generalGroupName);
204211

205212
return $this;
@@ -310,16 +317,21 @@ public function getAttributeSetSortOrder($entityTypeId, $sortOrder = null)
310317
* @param int|string $entityTypeId
311318
* @param string $name
312319
* @param int $sortOrder
320+
* @param int $setId
313321
* @return $this
314322
*/
315-
public function addAttributeSet($entityTypeId, $name, $sortOrder = null)
323+
public function addAttributeSet($entityTypeId, $name, $sortOrder = null, $setId = null)
316324
{
317325
$data = [
318326
'entity_type_id' => $this->getEntityTypeId($entityTypeId),
319327
'attribute_set_name' => $name,
320328
'sort_order' => $this->getAttributeSetSortOrder($entityTypeId, $sortOrder),
321329
];
322330

331+
if ($setId !== null) {
332+
$data['attribute_set_id'] = $setId;
333+
}
334+
323335
$setId = $this->getAttributeSet($entityTypeId, $name, 'attribute_set_id');
324336
if ($setId) {
325337
$this->updateAttributeSet($entityTypeId, $setId, $data);

app/code/Magento/Sales/Setup/SalesSetup.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,26 @@
1818
*/
1919
class SalesSetup extends \Magento\Eav\Setup\EavSetup
2020
{
21+
/**
22+
* This should be set explicitly
23+
*/
24+
const ORDER_ENTITY_TYPE_ID = 5;
25+
26+
/**
27+
* This should be set explicitly
28+
*/
29+
const INVOICE_PRODUCT_ENTITY_TYPE_ID = 6;
30+
31+
/**
32+
* This should be set explicitly
33+
*/
34+
const CREDITMEMO_PRODUCT_ENTITY_TYPE_ID = 7;
35+
36+
/**
37+
* This should be set explicitly
38+
*/
39+
const SHIPMENT_PRODUCT_ENTITY_TYPE_ID = 8;
40+
2141
/**
2242
* @var ScopeConfigInterface
2343
*/
@@ -214,27 +234,31 @@ public function getDefaultEntities()
214234
{
215235
$entities = [
216236
'order' => [
237+
'entity_type_id' => self::ORDER_ENTITY_TYPE_ID,
217238
'entity_model' => 'Magento\Sales\Model\ResourceModel\Order',
218239
'table' => 'sales_order',
219240
'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue',
220241
'increment_per_store' => true,
221242
'attributes' => [],
222243
],
223244
'invoice' => [
245+
'entity_type_id' => self::INVOICE_PRODUCT_ENTITY_TYPE_ID,
224246
'entity_model' => 'Magento\Sales\Model\ResourceModel\Order\Invoice',
225247
'table' => 'sales_invoice',
226248
'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue',
227249
'increment_per_store' => true,
228250
'attributes' => [],
229251
],
230252
'creditmemo' => [
253+
'entity_type_id' => self::CREDITMEMO_PRODUCT_ENTITY_TYPE_ID,
231254
'entity_model' => 'Magento\Sales\Model\ResourceModel\Order\Creditmemo',
232255
'table' => 'sales_creditmemo',
233256
'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue',
234257
'increment_per_store' => true,
235258
'attributes' => [],
236259
],
237260
'shipment' => [
261+
'entity_type_id' => self::SHIPMENT_PRODUCT_ENTITY_TYPE_ID,
238262
'entity_model' => 'Magento\Sales\Model\ResourceModel\Order\Shipment',
239263
'table' => 'sales_shipment',
240264
'increment_model' => 'Magento\Eav\Model\Entity\Increment\NumericValue',

0 commit comments

Comments
 (0)