Skip to content

Commit 83eb455

Browse files
author
cspruiell
committed
MAGETWO-59105: Errors on storefront after install for MPAF builds
- Merge remote-tracking branch 'mainline/develop' into MAGETWO-59105-SortOrder
2 parents debf84d + 6674762 commit 83eb455

File tree

12 files changed

+76
-46
lines changed

12 files changed

+76
-46
lines changed

app/code/Magento/Catalog/Model/Category.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
6565
*/
6666
const TREE_ROOT_ID = 1;
6767

68-
const CACHE_TAG = 'catalog_category';
68+
const CACHE_TAG = 'cat_c';
6969

7070
/**#@+
7171
* Constants

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
5858
/**
5959
* Product cache tag
6060
*/
61-
const CACHE_TAG = 'catalog_product';
61+
const CACHE_TAG = 'cat_p';
6262

6363
/**
6464
* Category product relation cache tag
6565
*/
66-
const CACHE_PRODUCT_CATEGORY_TAG = 'catalog_category_product';
66+
const CACHE_PRODUCT_CATEGORY_TAG = 'cat_c_p';
6767

6868
/**
6969
* Product Store Id

app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ protected function tearDown()
114114

115115
public function testGetIdentities()
116116
{
117-
$productTag = 'catalog_product_1';
118-
$categoryTag = 'catalog_category_product_1';
117+
$productTag = 'cat_p_1';
118+
$categoryTag = 'cat_c_p_1';
119119

120120
$this->productMock->expects($this->once())
121121
->method('getIdentities')

app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected function setUp()
3232
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
3333
$this->productTypeConfig = $this->getMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class);
3434
$this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false);
35-
$this->view = $helper->getObject(
35+
$this->view = $helper->getObject(
3636
\Magento\Catalog\Block\Product\View::class,
3737
['productTypeConfig' => $this->productTypeConfig, 'registry' => $this->registryMock]
3838
);
@@ -65,7 +65,7 @@ public function testShouldRenderQuantity()
6565

6666
public function testGetIdentities()
6767
{
68-
$productTags = ['catalog_product_1'];
68+
$productTags = ['cat_p_1'];
6969
$product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false);
7070
$category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false);
7171

@@ -84,6 +84,6 @@ public function testGetIdentities()
8484
]
8585
)
8686
);
87-
$this->assertEquals(['catalog_product_1', 'catalog_category_1'], $this->view->getIdentities());
87+
$this->assertEquals(['cat_p_1', 'cat_c_1'], $this->view->getIdentities());
8888
}
8989
}

app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -708,13 +708,13 @@ public function getIdentitiesProvider()
708708

709709
return [
710710
'no changes' => [
711-
['catalog_product_1'],
711+
['cat_p_1'],
712712
['id' => 1, 'name' => 'value', 'category_ids' => [1]],
713713
['id' => 1, 'name' => 'value', 'category_ids' => [1]],
714714
],
715715
'new product' => $this->getNewProductProviderData(),
716716
'status and category change' => [
717-
[0 => 'catalog_product_1', 1 => 'catalog_category_product_1', 2 => 'catalog_category_product_2'],
717+
[0 => 'cat_p_1', 1 => 'cat_c_p_1', 2 => 'cat_c_p_2'],
718718
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2],
719719
[
720720
'id' => 1,
@@ -726,18 +726,18 @@ public function getIdentitiesProvider()
726726
],
727727
],
728728
'status change only' => [
729-
[0 => 'catalog_product_1', 1 => 'catalog_category_product_7'],
729+
[0 => 'cat_p_1', 1 => 'cat_c_p_7'],
730730
['id' => 1, 'name' => 'value', 'category_ids' => [7], 'status' => 1],
731731
['id' => 1, 'name' => 'value', 'category_ids' => [7], 'status' => 2],
732732
],
733733
'status changed, category unassigned' => $this->getStatusAndCategoryChangesData(),
734734
'no status changes' => [
735-
[0 => 'catalog_product_1'],
735+
[0 => 'cat_p_1'],
736736
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
737737
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
738738
],
739739
'no stock status changes' => [
740-
[0 => 'catalog_product_1'],
740+
[0 => 'cat_p_1'],
741741
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
742742
[
743743
'id' => 1,
@@ -749,7 +749,7 @@ public function getIdentitiesProvider()
749749
],
750750
],
751751
'no stock status data 1' => [
752-
[0 => 'catalog_product_1'],
752+
[0 => 'cat_p_1'],
753753
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
754754
[
755755
'id' => 1,
@@ -760,7 +760,7 @@ public function getIdentitiesProvider()
760760
],
761761
],
762762
'no stock status data 2' => [
763-
[0 => 'catalog_product_1'],
763+
[0 => 'cat_p_1'],
764764
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
765765
[
766766
'id' => 1,
@@ -780,7 +780,7 @@ public function getIdentitiesProvider()
780780
private function getStatusAndCategoryChangesData()
781781
{
782782
return [
783-
[0 => 'catalog_product_1', 1 => 'catalog_category_product_5'],
783+
[0 => 'cat_p_1', 1 => 'cat_c_p_5'],
784784
['id' => 1, 'name' => 'value', 'category_ids' => [5], 'status' => 2],
785785
[
786786
'id' => 1,
@@ -799,7 +799,7 @@ private function getStatusAndCategoryChangesData()
799799
private function getNewProductProviderData()
800800
{
801801
return [
802-
['catalog_product_1', 'catalog_category_product_1'],
802+
['cat_p_1', 'cat_c_p_1'],
803803
null,
804804
[
805805
'id' => 1,
@@ -818,7 +818,7 @@ private function getNewProductProviderData()
818818
private function getStatusStockProviderData($extensionAttributesMock)
819819
{
820820
return [
821-
[0 => 'catalog_product_1', 1 => 'catalog_category_product_1'],
821+
[0 => 'cat_p_1', 1 => 'cat_c_p_1'],
822822
['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1],
823823
[
824824
'id' => 1,

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

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace Magento\CatalogImportExport\Model\Export;
77

8+
use Magento\Framework\DB\Ddl\Table;
89
use Magento\ImportExport\Model\Import;
910
use \Magento\Store\Model\Store;
1011
use \Magento\CatalogImportExport\Model\Import\Product as ImportProduct;
@@ -127,6 +128,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
127128
*/
128129
protected $_attributeTypes = [];
129130

131+
/**
132+
* Attributes defined by user
133+
*
134+
* @var array
135+
*/
136+
private $userDefinedAttributes = [];
137+
130138
/**
131139
* Product collection
132140
*
@@ -261,7 +269,11 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity
261269
*/
262270
protected $dateAttrCodes = [
263271
'special_from_date',
264-
'special_to_date'
272+
'special_to_date',
273+
'news_from_date',
274+
'news_to_date',
275+
'custom_design_from',
276+
'custom_design_to'
265277
];
266278

267279
/**
@@ -910,20 +922,24 @@ protected function collectRawData()
910922
}
911923
$fieldName = isset($this->_fieldsMap[$code]) ? $this->_fieldsMap[$code] : $code;
912924

913-
if (in_array($code, $this->dateAttrCodes)) {
914-
$attrValue = $this->_localeDate->formatDateTime(
915-
new \DateTime($attrValue),
916-
\IntlDateFormatter::SHORT,
917-
\IntlDateFormatter::NONE,
918-
null,
919-
date_default_timezone_get()
920-
);
921-
} else if ($this->_attributeTypes[$code] === 'datetime') {
922-
$attrValue = $this->_localeDate->formatDateTime(
923-
new \DateTime($attrValue),
924-
\IntlDateFormatter::SHORT,
925-
\IntlDateFormatter::SHORT
926-
);
925+
if ($this->_attributeTypes[$code] == 'datetime') {
926+
if (in_array($code, $this->dateAttrCodes)
927+
|| in_array($code, $this->userDefinedAttributes)
928+
) {
929+
$attrValue = $this->_localeDate->formatDateTime(
930+
new \DateTime($attrValue),
931+
\IntlDateFormatter::SHORT,
932+
\IntlDateFormatter::NONE,
933+
null,
934+
date_default_timezone_get()
935+
);
936+
} else {
937+
$attrValue = $this->_localeDate->formatDateTime(
938+
new \DateTime($attrValue),
939+
\IntlDateFormatter::SHORT,
940+
\IntlDateFormatter::SHORT
941+
);
942+
}
927943
}
928944

929945
if ($storeId != Store::DEFAULT_STORE_ID
@@ -1380,6 +1396,9 @@ protected function initAttributes()
13801396
$this->_attributeValues[$attribute->getAttributeCode()] = $this->getAttributeOptions($attribute);
13811397
$this->_attributeTypes[$attribute->getAttributeCode()] =
13821398
\Magento\ImportExport\Model\Import::getAttributeType($attribute);
1399+
if ($attribute->getIsUserDefined()) {
1400+
$this->userDefinedAttributes[] = $attribute->getAttributeCode();
1401+
}
13831402
}
13841403
return $this;
13851404
}

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,11 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity
217217
*/
218218
protected $dateAttrCodes = [
219219
'special_from_date',
220-
'special_to_date'
220+
'special_to_date',
221+
'news_from_date',
222+
'news_to_date',
223+
'custom_design_from',
224+
'custom_design_to'
221225
];
222226

223227
/**
@@ -1699,7 +1703,10 @@ protected function _saveProducts()
16991703

17001704
if (
17011705
'datetime' == $attribute->getBackendType()
1702-
&& in_array($attribute->getAttributeCode(), $this->dateAttrCodes)
1706+
&& (
1707+
in_array($attribute->getAttributeCode(), $this->dateAttrCodes)
1708+
|| $attribute->getIsUserDefined()
1709+
)
17031710
) {
17041711
$attrValue = $this->dateTime->formatDate($attrValue, false);
17051712
} else if ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) {
@@ -2533,7 +2540,7 @@ protected function _saveValidatedBunches()
25332540
$rowData = $this->_customFieldsMapping($rowData);
25342541

25352542
$this->validateRow($rowData, $source->key());
2536-
2543+
25372544
$source->next();
25382545
}
25392546
$this->checkUrlKeyDuplicates();

app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ public function testGetCustomerGroupId()
6262
public function testGetIdentities()
6363
{
6464
$this->_model->setProductId(1);
65-
$this->assertEquals(['catalog_product_1'], $this->_model->getIdentities());
65+
$this->assertEquals(['cat_p_1'], $this->_model->getIdentities());
6666
}
6767
}

app/code/Magento/Cms/Model/Block.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Block extends AbstractModel implements BlockInterface, IdentityInterface
2323
/**
2424
* CMS block cache tag
2525
*/
26-
const CACHE_TAG = 'cms_block';
26+
const CACHE_TAG = 'cms_b';
2727

2828
/**#@+
2929
* Block's statuses
@@ -36,7 +36,7 @@ class Block extends AbstractModel implements BlockInterface, IdentityInterface
3636
/**
3737
* @var string
3838
*/
39-
protected $_cacheTag = 'cms_block';
39+
protected $_cacheTag = self::CACHE_TAG;
4040

4141
/**
4242
* Prefix of model events names

app/code/Magento/Cms/Model/Page.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ class Page extends AbstractModel implements PageInterface, IdentityInterface
3939
/**
4040
* CMS page cache tag
4141
*/
42-
const CACHE_TAG = 'cms_page';
42+
const CACHE_TAG = 'cms_p';
4343

4444
/**
4545
* @var string
4646
*/
47-
protected $_cacheTag = 'cms_page';
47+
protected $_cacheTag = self::CACHE_TAG;
4848

4949
/**
5050
* Prefix of model events names

0 commit comments

Comments
 (0)