Skip to content

Commit ac3411e

Browse files
author
Dmytro Aponasenko
committed
Merge branch 'develop' of https://github.corp.ebay.com/magento2/magento2ce into develop
2 parents 839e94a + 4197c31 commit ac3411e

File tree

42 files changed

+309
-165
lines changed

Some content is hidden

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

42 files changed

+309
-165
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/AddAttributeToTemplate.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public function execute()
5555

5656
$attribute->setAttributeSetId($attributeSet->getId())->loadEntityAttributeIdBySet();
5757

58-
$attribute->setEntityTypeId($attributeSet->getEntityTypeId())
59-
->setAttributeSetId($request->getParam('template_id'))
58+
$attribute->setAttributeSetId($request->getParam('template_id'))
6059
->setAttributeGroupId($attributeGroup->getId())
6160
->setSortOrder('0')
6261
->save();

app/code/Magento/Catalog/Controller/Adminhtml/Product/Save.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public function execute()
6464
$storeId = $this->getRequest()->getParam('store');
6565
$redirectBack = $this->getRequest()->getParam('back', false);
6666
$productId = $this->getRequest()->getParam('id');
67+
$resultRedirect = $this->resultRedirectFactory->create();
6768

6869
$data = $this->getRequest()->getPost();
6970
if ($data) {
@@ -122,9 +123,12 @@ public function execute()
122123
$this->_session->setProductData($data);
123124
$redirectBack = $productId ? true : 'new';
124125
}
126+
} else {
127+
$resultRedirect->setPath('catalog/*/', ['store' => $storeId]);
128+
$this->messageManager->addError('No data to save');
129+
return $resultRedirect;
125130
}
126131

127-
$resultRedirect = $this->resultRedirectFactory->create();
128132
if ($redirectBack === 'new') {
129133
$resultRedirect->setPath(
130134
'catalog/*/new',

app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ protected function _fillTemporaryFlatTable(array $tables, $storeId, $valueFieldS
209209
$statusTable = $this->_getTemporaryTableName($status->getBackendTable());
210210
$statusConditions = [
211211
'e.entity_id = dstatus.entity_id',
212-
'dstatus.entity_type_id = ' . (int)$status->getEntityTypeId(),
213212
'dstatus.store_id = ' . (int)$storeId,
214213
'dstatus.attribute_id = ' . (int)$status->getId(),
215214
];
@@ -291,8 +290,6 @@ protected function _updateTemporaryTableByStoreValues(
291290
$attributeCode = $attribute->getAttributeCode();
292291
if ($attribute->getBackend()->getType() != 'static') {
293292
$joinCondition = 't.entity_id = e.entity_id' .
294-
' AND t.entity_type_id = ' .
295-
$attribute->getEntityTypeId() .
296293
' AND t.attribute_id=' .
297294
$attribute->getId() .
298295
' AND t.store_id = ' .

app/code/Magento/Catalog/Model/Product/Attribute/Backend/Sku.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,11 @@ protected function _getLastSimilarAttributeValueIncrement($attribute, $object)
104104
$adapter = $this->getAttribute()->getEntity()->getReadConnection();
105105
$select = $adapter->select();
106106
$value = $object->getData($attribute->getAttributeCode());
107-
$bind = ['entity_type_id' => $attribute->getEntityTypeId(), 'attribute_code' => trim($value) . '-%'];
107+
$bind = ['attribute_code' => trim($value) . '-%'];
108108

109109
$select->from(
110110
$this->getTable(),
111111
$attribute->getAttributeCode()
112-
)->where(
113-
'entity_type_id = :entity_type_id'
114112
)->where(
115113
$attribute->getAttributeCode() . ' LIKE :attribute_code'
116114
)->order(

app/code/Magento/Catalog/Model/Resource/AbstractResource.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ protected function _saveAttributeValue($object, $attribute, $value)
257257

258258
$data = new \Magento\Framework\Object(
259259
[
260-
'entity_type_id' => $attribute->getEntityTypeId(),
261260
'attribute_id' => $attribute->getAttributeId(),
262261
'store_id' => $storeId,
263262
'entity_id' => $object->getEntityId(),
@@ -311,7 +310,6 @@ protected function _insertAttribute($object, $attribute, $value)
311310

312311
$select = $this->_getReadAdapter()->select()
313312
->from($table)
314-
->where('entity_type_id = ?', $attribute->getEntityTypeId())
315313
->where('attribute_id = ?', $attribute->getAttributeId())
316314
->where('store_id = ?', $this->getDefaultStoreId())
317315
->where('entity_id = ?', $object->getEntityId());
@@ -320,7 +318,6 @@ protected function _insertAttribute($object, $attribute, $value)
320318
if (!$row) {
321319
$data = new \Magento\Framework\Object(
322320
[
323-
'entity_type_id' => $attribute->getEntityTypeId(),
324321
'attribute_id' => $attribute->getAttributeId(),
325322
'store_id' => $this->getDefaultStoreId(),
326323
'entity_id' => $object->getEntityId(),
@@ -366,12 +363,10 @@ protected function _updateAttributeForStore($object, $attribute, $value, $storeI
366363
$entityIdField = $attribute->getBackend()->getEntityIdField();
367364
$select = $adapter->select()
368365
->from($table, 'value_id')
369-
->where('entity_type_id = :entity_type_id')
370366
->where("$entityIdField = :entity_field_id")
371367
->where('store_id = :store_id')
372368
->where('attribute_id = :attribute_id');
373369
$bind = [
374-
'entity_type_id' => $object->getEntityTypeId(),
375370
'entity_field_id' => $object->getId(),
376371
'store_id' => $storeId,
377372
'attribute_id' => $attribute->getId(),
@@ -388,7 +383,6 @@ protected function _updateAttributeForStore($object, $attribute, $value, $storeI
388383
} else {
389384
$bind = [
390385
$entityIdField => (int) $object->getId(),
391-
'entity_type_id' => (int) $object->getEntityTypeId(),
392386
'attribute_id' => (int) $attribute->getId(),
393387
'value' => $this->_prepareValueForSave($value, $attribute),
394388
'store_id' => (int) $storeId,
@@ -439,7 +433,6 @@ protected function _deleteAttributes($object, $table, $info)
439433

440434
$condition = [
441435
$entityIdField . ' = ?' => $object->getId(),
442-
'entity_type_id = ?' => $object->getEntityTypeId(),
443436
];
444437

445438
/**
@@ -595,11 +588,10 @@ public function getAttributeRawValue($entityId, $attribute, $store)
595588
$select = $adapter->select()
596589
->from(['default_value' => $table], ['attribute_id'])
597590
->where('default_value.attribute_id IN (?)', array_keys($_attributes))
598-
->where('default_value.entity_type_id = :entity_type_id')
599591
->where('default_value.entity_id = :entity_id')
600592
->where('default_value.store_id = ?', 0);
601593

602-
$bind = ['entity_type_id' => $this->getTypeId(), 'entity_id' => $entityId];
594+
$bind = ['entity_id' => $entityId];
603595

604596
if ($store != $this->getDefaultStoreId()) {
605597
$valueExpr = $adapter->getCheckSql(
@@ -609,7 +601,6 @@ public function getAttributeRawValue($entityId, $attribute, $store)
609601
);
610602
$joinCondition = [
611603
$adapter->quoteInto('store_value.attribute_id IN (?)', array_keys($_attributes)),
612-
'store_value.entity_type_id = :entity_type_id',
613604
'store_value.entity_id = :entity_id',
614605
'store_value.store_id = :store_id',
615606
];

app/code/Magento/Catalog/Model/Resource/Attribute.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ protected function _clearUselessAttributeValues(\Magento\Framework\Model\Abstrac
8989
$attributeStoreIds = array_keys($this->_storeManager->getStores());
9090
if (!empty($attributeStoreIds)) {
9191
$delCondition = [
92-
'entity_type_id=?' => $object->getEntityTypeId(),
9392
'attribute_id = ?' => $object->getId(),
9493
'store_id IN(?)' => $attributeStoreIds,
9594
];
@@ -146,7 +145,6 @@ public function deleteEntity(\Magento\Framework\Model\AbstractModel $object)
146145
);
147146

148147
$clearCondition = [
149-
'entity_type_id =?' => $attribute->getEntityTypeId(),
150148
'attribute_id =?' => $attribute->getId(),
151149
'entity_id IN (?)' => $select,
152150
];

app/code/Magento/Catalog/Model/Resource/Collection/AbstractCollection.php

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -133,39 +133,48 @@ protected function _getLoadAttributesSelect($table, $attributeIds = [])
133133
$attributeIds = $this->_selectAttributes;
134134
}
135135
$storeId = $this->getStoreId();
136+
$adapter = $this->getConnection();
137+
$entityIdField = $this->getEntity()->getEntityIdField();
136138

137139
if ($storeId) {
138-
$adapter = $this->getConnection();
139-
$entityIdField = $this->getEntity()->getEntityIdField();
140140
$joinCondition = [
141141
't_s.attribute_id = t_d.attribute_id',
142142
't_s.entity_id = t_d.entity_id',
143143
$adapter->quoteInto('t_s.store_id = ?', $storeId),
144144
];
145+
145146
$select = $adapter->select()->from(
146147
['t_d' => $table],
147148
[$entityIdField, 'attribute_id']
148-
)->joinLeft(
149-
['t_s' => $table],
150-
implode(' AND ', $joinCondition),
151-
[]
152-
)->where(
153-
't_d.entity_type_id = ?',
154-
$this->getEntity()->getTypeId()
155149
)->where(
156150
"t_d.{$entityIdField} IN (?)",
157151
array_keys($this->_itemsById)
158152
)->where(
159153
't_d.attribute_id IN (?)',
160154
$attributeIds
155+
)->joinLeft(
156+
['t_s' => $table],
157+
implode(' AND ', $joinCondition),
158+
[]
161159
)->where(
162160
't_d.store_id = ?',
163161
$adapter->getIfNullSql('t_s.store_id', \Magento\Store\Model\Store::DEFAULT_STORE_ID)
164162
);
165163
} else {
166-
$select = parent::_getLoadAttributesSelect($table)->where('store_id = ?', $this->getDefaultStoreId());
164+
$select = $adapter->select()->from(
165+
$table,
166+
[$entityIdField, 'attribute_id']
167+
)->where(
168+
"{$entityIdField} IN (?)",
169+
array_keys($this->_itemsById)
170+
)->where(
171+
'attribute_id IN (?)',
172+
$attributeIds
173+
)->where(
174+
'store_id = ?',
175+
$this->getDefaultStoreId()
176+
);
167177
}
168-
169178
return $select;
170179
}
171180

app/code/Magento/Catalog/Model/Resource/Product.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public function __construct(
117117
*/
118118
protected function _getDefaultAttributes()
119119
{
120-
return ['entity_id', 'entity_type_id', 'attribute_set_id', 'type_id', 'created_at', 'updated_at'];
120+
return ['entity_id', 'attribute_set_id', 'type_id', 'created_at', 'updated_at'];
121121
}
122122

123123
/**
@@ -451,9 +451,7 @@ public function canBeShowInCategory($product, $categoryId)
451451
*/
452452
public function duplicate($oldId, $newId)
453453
{
454-
$adapter = $this->_getWriteAdapter();
455454
$eavTables = ['datetime', 'decimal', 'int', 'text', 'varchar'];
456-
457455
$adapter = $this->_getWriteAdapter();
458456

459457
// duplicate EAV store values
@@ -463,7 +461,6 @@ public function duplicate($oldId, $newId)
463461
$select = $adapter->select()->from(
464462
$tableName,
465463
[
466-
'entity_type_id',
467464
'attribute_id',
468465
'store_id',
469466
'entity_id' => new \Zend_Db_Expr($adapter->quote($newId)),
@@ -481,7 +478,7 @@ public function duplicate($oldId, $newId)
481478
$adapter->insertFromSelect(
482479
$select,
483480
$tableName,
484-
['entity_type_id', 'attribute_id', 'store_id', 'entity_id', 'value'],
481+
['attribute_id', 'store_id', 'entity_id', 'value'],
485482
\Magento\Framework\DB\Adapter\AdapterInterface::INSERT_ON_DUPLICATE
486483
)
487484
);

app/code/Magento/Catalog/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="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
9-
<module name="Magento_Catalog" schema_version="2.0.0">
9+
<module name="Magento_Catalog" schema_version="2.0.0.1">
1010
<sequence>
1111
<module name="Magento_Eav"/>
1212
<module name="Magento_Cms"/>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
/* @var $installer \Magento\Catalog\Model\Resource\Setup */
8+
$installer = $this;
9+
10+
$installer->startSetup();
11+
12+
$connection = $installer->getConnection();
13+
$connection->dropForeignKey(
14+
$installer->getTable('catalog_product_entity'),
15+
'FK_CAT_PRD_ENTT_ENTT_TYPE_ID_EAV_ENTT_TYPE_ENTT_TYPE_ID'
16+
);
17+
18+
//Drop entity_type_id column for catalog product entities
19+
$connection->dropColumn($installer->getTable('catalog_product_entity'), 'entity_type_id');
20+
$connection->dropColumn($installer->getTable('catalog_product_entity_datetime'), 'entity_type_id');
21+
$connection->dropColumn($installer->getTable('catalog_product_entity_decimal'), 'entity_type_id');
22+
$connection->dropColumn($installer->getTable('catalog_product_entity_gallery'), 'entity_type_id');
23+
$connection->dropColumn($installer->getTable('catalog_product_entity_int'), 'entity_type_id');
24+
$connection->dropColumn($installer->getTable('catalog_product_entity_text'), 'entity_type_id');
25+
$connection->dropColumn($installer->getTable('catalog_product_entity_varchar'), 'entity_type_id');
26+
27+
//Drop entity_type_id column for catalog category entities
28+
$connection->dropColumn($installer->getTable('catalog_category_entity'), 'entity_type_id');
29+
$connection->dropColumn($installer->getTable('catalog_category_entity_datetime'), 'entity_type_id');
30+
$connection->dropColumn($installer->getTable('catalog_category_entity_decimal'), 'entity_type_id');
31+
$connection->dropColumn($installer->getTable('catalog_category_entity_int'), 'entity_type_id');
32+
$connection->dropColumn($installer->getTable('catalog_category_entity_text'), 'entity_type_id');
33+
$connection->dropColumn($installer->getTable('catalog_category_entity_varchar'), 'entity_type_id');
34+
35+
$installer->endSetup();

app/code/Magento/CatalogImportExport/Model/Import/Product.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,6 @@ protected function _saveProductAttributes(array $attributesData)
11721172
foreach ($storeValues as $storeId => $storeValue) {
11731173
$tableData[] = [
11741174
'entity_id' => $productId,
1175-
'entity_type_id' => $this->_entityTypeId,
11761175
'attribute_id' => $attributeId,
11771176
'store_id' => $storeId,
11781177
'value' => $storeValue,
@@ -1192,9 +1191,6 @@ protected function _saveProductAttributes(array $attributesData)
11921191
) . $this->_connection->quoteInto(
11931192
' AND entity_id = ?',
11941193
$productId
1195-
) . $this->_connection->quoteInto(
1196-
' AND entity_type_id = ?',
1197-
$this->_entityTypeId
11981194
);
11991195
$this->_connection->delete($tableName, $where);
12001196
}
@@ -1325,7 +1321,6 @@ protected function _saveProducts()
13251321
// new row
13261322
if (!$productLimit || $productsQty < $productLimit) {
13271323
$entityRowsIn[$rowSku] = [
1328-
'entity_type_id' => $this->_entityTypeId,
13291324
'attribute_set_id' => $this->_newSku[$rowSku]['attr_set_id'],
13301325
'type_id' => $this->_newSku[$rowSku]['type_id'],
13311326
'sku' => $rowSku,

app/code/Magento/Customer/Model/Address.php

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,9 @@ public function updateData(AddressInterface $address)
128128
// Need to explicitly set this due to discrepancy in the keys between model and data object
129129
$this->setIsDefaultBilling($address->isDefaultBilling());
130130
$this->setIsDefaultShipping($address->isDefaultShipping());
131-
132-
// Need to use attribute set or future updates can cause data loss
133131
if (!$this->getAttributeSetId()) {
134132
$this->setAttributeSetId(AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS);
135133
}
136-
137134
$customAttributes = $address->getCustomAttributes();
138135
if (!is_null($customAttributes)) {
139136
foreach ($customAttributes as $attribute) {
@@ -255,21 +252,6 @@ public function getEntityType()
255252
return $this->_getResource()->getEntityType();
256253
}
257254

258-
/**
259-
* Return Entity Type ID
260-
*
261-
* @return int
262-
*/
263-
public function getEntityTypeId()
264-
{
265-
$entityTypeId = $this->getData('entity_type_id');
266-
if (!$entityTypeId) {
267-
$entityTypeId = $this->getEntityType()->getId();
268-
$this->setData('entity_type_id', $entityTypeId);
269-
}
270-
return $entityTypeId;
271-
}
272-
273255
/**
274256
* Return Region ID
275257
*
@@ -299,4 +281,14 @@ protected function _createCustomer()
299281
{
300282
return $this->_customerFactory->create();
301283
}
284+
285+
/**
286+
* Return Entity Type ID
287+
*
288+
* @return int
289+
*/
290+
public function getEntityTypeId()
291+
{
292+
return $this->getEntityType()->getId();
293+
}
302294
}

app/code/Magento/Customer/Model/Customer.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,21 +1217,6 @@ public function getEntityType()
12171217
return $this->_getResource()->getEntityType();
12181218
}
12191219

1220-
/**
1221-
* Return Entity Type ID
1222-
*
1223-
* @return int
1224-
*/
1225-
public function getEntityTypeId()
1226-
{
1227-
$entityTypeId = $this->getData('entity_type_id');
1228-
if (!$entityTypeId) {
1229-
$entityTypeId = $this->getEntityType()->getId();
1230-
$this->setData('entity_type_id', $entityTypeId);
1231-
}
1232-
return $entityTypeId;
1233-
}
1234-
12351220
/**
12361221
* Get either first store ID from a set website or the provided as default
12371222
*

0 commit comments

Comments
 (0)