diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php index b1f9dbf8c327a46176208cec90f8130065d8400a..9e855e05c7ce388dd52c11829882d5b46f634d02 100644 --- a/app/code/Magento/Catalog/Model/Category.php +++ b/app/code/Magento/Catalog/Model/Category.php @@ -65,7 +65,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements */ const TREE_ROOT_ID = 1; - const CACHE_TAG = 'catalog_category'; + const CACHE_TAG = 'cat_c'; /**#@+ * Constants diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php index 49df6fd57c323bc1f12f65c590ff39ff4e041123..9e9f18e0113717ad6853ea5d4512661a897e926c 100644 --- a/app/code/Magento/Catalog/Model/Product.php +++ b/app/code/Magento/Catalog/Model/Product.php @@ -58,12 +58,12 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements /** * Product cache tag */ - const CACHE_TAG = 'catalog_product'; + const CACHE_TAG = 'cat_p'; /** * Category product relation cache tag */ - const CACHE_PRODUCT_CATEGORY_TAG = 'catalog_category_product'; + const CACHE_PRODUCT_CATEGORY_TAG = 'cat_c_p'; /** * Product Store Id diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php index 38ef297e684267c17c128298147343c979c43f85..f420f140b35820e3cbcebf986ed305217523aab2 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ListProductTest.php @@ -114,8 +114,8 @@ class ListProductTest extends \PHPUnit_Framework_TestCase public function testGetIdentities() { - $productTag = 'catalog_product_1'; - $categoryTag = 'catalog_category_product_1'; + $productTag = 'cat_p_1'; + $categoryTag = 'cat_c_p_1'; $this->productMock->expects($this->once()) ->method('getIdentities') diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php index d030cf456b6b13e9e8dfa240df6252d4016decd4..f0287e05a4b7b3b94f837e9adec3e4a43667e34c 100644 --- a/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Block/Product/ViewTest.php @@ -32,7 +32,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->productTypeConfig = $this->getMock(\Magento\Catalog\Model\ProductTypes\ConfigInterface::class); $this->registryMock = $this->getMock(\Magento\Framework\Registry::class, [], [], '', false); - $this->view = $helper->getObject( + $this->view = $helper->getObject( \Magento\Catalog\Block\Product\View::class, ['productTypeConfig' => $this->productTypeConfig, 'registry' => $this->registryMock] ); @@ -65,7 +65,7 @@ class ViewTest extends \PHPUnit_Framework_TestCase public function testGetIdentities() { - $productTags = ['catalog_product_1']; + $productTags = ['cat_p_1']; $product = $this->getMock(\Magento\Catalog\Model\Product::class, [], [], '', false); $category = $this->getMock(\Magento\Catalog\Model\Category::class, [], [], '', false); @@ -84,6 +84,6 @@ class ViewTest extends \PHPUnit_Framework_TestCase ] ) ); - $this->assertEquals(['catalog_product_1', 'catalog_category_1'], $this->view->getIdentities()); + $this->assertEquals(['cat_p_1', 'cat_c_1'], $this->view->getIdentities()); } } diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php index b586436b5680d942daa4f9fc6f884138f0a7eeb5..f8e162dff45f390156e63c779ce2c2818d723aa5 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductTest.php @@ -708,13 +708,13 @@ class ProductTest extends \PHPUnit_Framework_TestCase return [ 'no changes' => [ - ['catalog_product_1'], + ['cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1]], ['id' => 1, 'name' => 'value', 'category_ids' => [1]], ], 'new product' => $this->getNewProductProviderData(), 'status and category change' => [ - [0 => 'catalog_product_1', 1 => 'catalog_category_product_1', 2 => 'catalog_category_product_2'], + [0 => 'cat_p_1', 1 => 'cat_c_p_1', 2 => 'cat_c_p_2'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 2], [ 'id' => 1, @@ -726,18 +726,18 @@ class ProductTest extends \PHPUnit_Framework_TestCase ], ], 'status change only' => [ - [0 => 'catalog_product_1', 1 => 'catalog_category_product_7'], + [0 => 'cat_p_1', 1 => 'cat_c_p_7'], ['id' => 1, 'name' => 'value', 'category_ids' => [7], 'status' => 1], ['id' => 1, 'name' => 'value', 'category_ids' => [7], 'status' => 2], ], 'status changed, category unassigned' => $this->getStatusAndCategoryChangesData(), 'no status changes' => [ - [0 => 'catalog_product_1'], + [0 => 'cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], ], 'no stock status changes' => [ - [0 => 'catalog_product_1'], + [0 => 'cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], [ 'id' => 1, @@ -749,7 +749,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase ], ], 'no stock status data 1' => [ - [0 => 'catalog_product_1'], + [0 => 'cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], [ 'id' => 1, @@ -760,7 +760,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase ], ], 'no stock status data 2' => [ - [0 => 'catalog_product_1'], + [0 => 'cat_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], [ 'id' => 1, @@ -780,7 +780,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase private function getStatusAndCategoryChangesData() { return [ - [0 => 'catalog_product_1', 1 => 'catalog_category_product_5'], + [0 => 'cat_p_1', 1 => 'cat_c_p_5'], ['id' => 1, 'name' => 'value', 'category_ids' => [5], 'status' => 2], [ 'id' => 1, @@ -799,7 +799,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase private function getNewProductProviderData() { return [ - ['catalog_product_1', 'catalog_category_product_1'], + ['cat_p_1', 'cat_c_p_1'], null, [ 'id' => 1, @@ -818,7 +818,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase private function getStatusStockProviderData($extensionAttributesMock) { return [ - [0 => 'catalog_product_1', 1 => 'catalog_category_product_1'], + [0 => 'cat_p_1', 1 => 'cat_c_p_1'], ['id' => 1, 'name' => 'value', 'category_ids' => [1], 'status' => 1], [ 'id' => 1, diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php index 2abd8d97ebc01b07bf786173e50969688d4388f1..86b150062d3c057afe500a6d76aac3665690ba87 100644 --- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php @@ -5,6 +5,7 @@ */ namespace Magento\CatalogImportExport\Model\Export; +use Magento\Framework\DB\Ddl\Table; use Magento\ImportExport\Model\Import; use \Magento\Store\Model\Store; use \Magento\CatalogImportExport\Model\Import\Product as ImportProduct; @@ -127,6 +128,13 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity */ protected $_attributeTypes = []; + /** + * Attributes defined by user + * + * @var array + */ + private $userDefinedAttributes = []; + /** * Product collection * @@ -261,7 +269,11 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity */ protected $dateAttrCodes = [ 'special_from_date', - 'special_to_date' + 'special_to_date', + 'news_from_date', + 'news_to_date', + 'custom_design_from', + 'custom_design_to' ]; /** @@ -910,20 +922,24 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity } $fieldName = isset($this->_fieldsMap[$code]) ? $this->_fieldsMap[$code] : $code; - if (in_array($code, $this->dateAttrCodes)) { - $attrValue = $this->_localeDate->formatDateTime( - new \DateTime($attrValue), - \IntlDateFormatter::SHORT, - \IntlDateFormatter::NONE, - null, - date_default_timezone_get() - ); - } else if ($this->_attributeTypes[$code] === 'datetime') { - $attrValue = $this->_localeDate->formatDateTime( - new \DateTime($attrValue), - \IntlDateFormatter::SHORT, - \IntlDateFormatter::SHORT - ); + if ($this->_attributeTypes[$code] == 'datetime') { + if (in_array($code, $this->dateAttrCodes) + || in_array($code, $this->userDefinedAttributes) + ) { + $attrValue = $this->_localeDate->formatDateTime( + new \DateTime($attrValue), + \IntlDateFormatter::SHORT, + \IntlDateFormatter::NONE, + null, + date_default_timezone_get() + ); + } else { + $attrValue = $this->_localeDate->formatDateTime( + new \DateTime($attrValue), + \IntlDateFormatter::SHORT, + \IntlDateFormatter::SHORT + ); + } } if ($storeId != Store::DEFAULT_STORE_ID @@ -1380,6 +1396,9 @@ class Product extends \Magento\ImportExport\Model\Export\Entity\AbstractEntity $this->_attributeValues[$attribute->getAttributeCode()] = $this->getAttributeOptions($attribute); $this->_attributeTypes[$attribute->getAttributeCode()] = \Magento\ImportExport\Model\Import::getAttributeType($attribute); + if ($attribute->getIsUserDefined()) { + $this->userDefinedAttributes[] = $attribute->getAttributeCode(); + } } return $this; } diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product.php b/app/code/Magento/CatalogImportExport/Model/Import/Product.php index a0feddec6529441ee5f3530bde7db9636fc88895..16df0866135a7f07760134c7aff9a0b15bc6fb01 100644 --- a/app/code/Magento/CatalogImportExport/Model/Import/Product.php +++ b/app/code/Magento/CatalogImportExport/Model/Import/Product.php @@ -217,7 +217,11 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity */ protected $dateAttrCodes = [ 'special_from_date', - 'special_to_date' + 'special_to_date', + 'news_from_date', + 'news_to_date', + 'custom_design_from', + 'custom_design_to' ]; /** @@ -1699,7 +1703,10 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity if ( 'datetime' == $attribute->getBackendType() - && in_array($attribute->getAttributeCode(), $this->dateAttrCodes) + && ( + in_array($attribute->getAttributeCode(), $this->dateAttrCodes) + || $attribute->getIsUserDefined() + ) ) { $attrValue = $this->dateTime->formatDate($attrValue, false); } else if ('datetime' == $attribute->getBackendType() && strtotime($attrValue)) { @@ -2533,7 +2540,7 @@ class Product extends \Magento\ImportExport\Model\Import\Entity\AbstractEntity $rowData = $this->_customFieldsMapping($rowData); $this->validateRow($rowData, $source->key()); - + $source->next(); } $this->checkUrlKeyDuplicates(); diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php index aef8141e70f340862e7c8f610cdfbf6cd4d6cf8d..dfb8073e718a7f31dd316a88efc7bf9b373dcd60 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Adminhtml/Stock/ItemTest.php @@ -62,6 +62,6 @@ class ItemTest extends \PHPUnit_Framework_TestCase public function testGetIdentities() { $this->_model->setProductId(1); - $this->assertEquals(['catalog_product_1'], $this->_model->getIdentities()); + $this->assertEquals(['cat_p_1'], $this->_model->getIdentities()); } } diff --git a/app/code/Magento/Cms/Model/Block.php b/app/code/Magento/Cms/Model/Block.php index d87f0f0d18884b6c31672fc5fdae32cd47e99c22..b25d433b0fee4f96618a31111940f9d410d9f006 100644 --- a/app/code/Magento/Cms/Model/Block.php +++ b/app/code/Magento/Cms/Model/Block.php @@ -23,7 +23,7 @@ class Block extends AbstractModel implements BlockInterface, IdentityInterface /** * CMS block cache tag */ - const CACHE_TAG = 'cms_block'; + const CACHE_TAG = 'cms_b'; /**#@+ * Block's statuses @@ -36,7 +36,7 @@ class Block extends AbstractModel implements BlockInterface, IdentityInterface /** * @var string */ - protected $_cacheTag = 'cms_block'; + protected $_cacheTag = self::CACHE_TAG; /** * Prefix of model events names diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index 20c2e0547193160643feddf1ddded16208e74a57..f98b56d82db03660e8a81353332a089f6739d37d 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -39,12 +39,12 @@ class Page extends AbstractModel implements PageInterface, IdentityInterface /** * CMS page cache tag */ - const CACHE_TAG = 'cms_page'; + const CACHE_TAG = 'cms_p'; /** * @var string */ - protected $_cacheTag = 'cms_page'; + protected $_cacheTag = self::CACHE_TAG; /** * Prefix of model events names diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 43ac499b8bd9dfce4312896c97ab506a4c93f02d..a5c1f07c164156a0941b0f8da05c43bdff644b5e 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -388,9 +388,13 @@ class ProductTest extends \Magento\TestFramework\Indexer\TestCase ); $productAfterImport->load($productBeforeImport->getId()); $this->assertEquals( - @strtotime($row['news_from_date']), + @strtotime(date('m/d/Y', @strtotime($row['news_from_date']))), @strtotime($productAfterImport->getNewsFromDate()) ); + $this->assertEquals( + @strtotime($row['news_to_date']), + @strtotime($productAfterImport->getNewsToDate()) + ); unset($productAfterImport); } unset($productsBeforeImport, $product); diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_datetime.csv b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_datetime.csv index ae7e27dbd95c0984548142c93c5d4e35afa0cc20..265e29fab65bb88f469454a7c77185c654e26acc 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_datetime.csv +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/products_to_import_with_datetime.csv @@ -1,4 +1,4 @@ -sku,news_from_date -simple1,"1/1/2015 20:00" -simple2,"10/8/2012 23:58" -simple3,"12/31/1998 17:30" +sku,news_from_date,news_to_date +simple1,"1/1/2015 20:00","1/2/2015" +simple2,"10/8/2012 23:58","1/3/2015" +simple3,"12/31/1998 17:30","1/4/2015"