diff --git a/app/code/Magento/Catalog/Model/Resource/Helper.php b/app/code/Magento/Catalog/Model/Resource/Helper.php index ef2f15133bd8e531a2558f802d1028dc84d004ea..fcd489d68642d628bbe7693fcf3c24cf09f5726a 100644 --- a/app/code/Magento/Catalog/Model/Resource/Helper.php +++ b/app/code/Magento/Catalog/Model/Resource/Helper.php @@ -6,14 +6,10 @@ namespace Magento\Catalog\Model\Resource; /** * Eav Mysql resource helper model - * - * @author Magento Core Team <core@magentocommerce.com> */ class Helper extends \Magento\Eav\Model\Resource\Helper { /** - * Construct - * * @param \Magento\Framework\App\Resource $resource * @param string $modulePrefix */ @@ -21,61 +17,4 @@ class Helper extends \Magento\Eav\Model\Resource\Helper { parent::__construct($resource, $modulePrefix); } - - /** - * Compare Flat style with Describe style columns - * If column a different - return false - * - * @param array $column - * @param array $describe - * @return bool - */ - public function compareIndexColumnProperties($column, $describe) - { - $type = $column['type']; - if (isset($column['length'])) { - $type = sprintf('%s(%s)', $type[0], $column['length']); - } else { - $type = $type[0]; - } - $length = null; - $precision = null; - $scale = null; - - $matches = []; - if (preg_match('/^((?:var)?char)\((\d+)\)/', $type, $matches)) { - $type = $matches[1]; - $length = $matches[2]; - } elseif (preg_match('/^decimal\((\d+),(\d+)\)/', $type, $matches)) { - $type = 'decimal'; - $precision = $matches[1]; - $scale = $matches[2]; - } elseif (preg_match('/^float\((\d+),(\d+)\)/', $type, $matches)) { - $type = 'float'; - $precision = $matches[1]; - $scale = $matches[2]; - } elseif (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)?/', $type, $matches)) { - $type = $matches[1]; - } - - return $describe['DATA_TYPE'] == $type && - $describe['DEFAULT'] == $column['default'] && - (bool)$describe['NULLABLE'] == (bool)$column['nullable'] && - (bool)$describe['UNSIGNED'] == (bool)$column['unsigned'] && - $describe['LENGTH'] == $length && - $describe['SCALE'] == $scale && - $describe['PRECISION'] == $precision; - } - - /** - * Getting condition isNull(f1,f2) IS NOT Null - * - * @param string $firstField - * @param string $secondField - * @return string - */ - public function getIsNullNotNullCondition($firstField, $secondField) - { - return sprintf('%s IS NOT NULL', $this->_getReadAdapter()->getIfNullSql($firstField, $secondField)); - } } diff --git a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php index f88c278afe41d2d4248373f673c46989e7786291..8c8f8d5ed1302601fe726fcd91ee449be1f66ffc 100644 --- a/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php +++ b/app/code/Magento/Catalog/Model/Resource/Product/Indexer/Eav/Source.php @@ -143,6 +143,7 @@ class Source extends AbstractEav $subSelect->where('d.entity_id IN(?)', $entityIds); } + $ifNullSql = $adapter->getIfNullSql('pis.value', 'pid.value'); /**@var $select \Magento\Framework\DB\Select*/ $select = $adapter->select()->distinct(true)->from( ['pid' => new \Zend_Db_Expr(sprintf('(%s)', $subSelect->assemble()))], @@ -156,14 +157,14 @@ class Source extends AbstractEav 'pid.entity_id', 'pid.attribute_id', 'pid.store_id', - 'value' => $adapter->getIfNullSql('pis.value', 'pid.value'), + 'value' => $ifNullSql, ] )->where( 'pid.attribute_id IN(?)', $attrIds ); - $select->where($this->_resourceHelper->getIsNullNotNullCondition('pis.value', 'pid.value')); + $select->where($ifNullSql . ' IS NOT NULL'); /** * Exclude attribute values that contains NULL diff --git a/app/code/Magento/Catalog/Model/Resource/Setup.php b/app/code/Magento/Catalog/Model/Resource/Setup.php index bb2713d989c664079be242150cb4b90e357169a8..8fa1f596b380fd683324bf268fee9346b6afe4bc 100644 --- a/app/code/Magento/Catalog/Model/Resource/Setup.php +++ b/app/code/Magento/Catalog/Model/Resource/Setup.php @@ -59,23 +59,13 @@ class Setup extends \Magento\Eav\Model\Entity\Setup * * @param array $data * @return \Magento\Catalog\Model\Category + * @codeCoverageIgnore */ public function createCategory($data = []) { return $this->_categoryFactory->create($data); } - /** - * Creates eav attribute resource model - * - * @param array $data - * @return \Magento\Catalog\Model\Resource\Eav\Attribute - */ - public function createEavAttributeResource($data = []) - { - return $this->_eavAttributeResourceFactory->create($data); - } - /** * Default entites and attributes * @@ -828,41 +818,4 @@ class Setup extends \Magento\Eav\Model\Entity\Setup ] ]; } - - /** - * Returns category entity row by category id - * - * @param int $entityId - * @return array - */ - protected function _getCategoryEntityRow($entityId) - { - $select = $this->getConnection()->select(); - - $select->from($this->getTable('catalog_category_entity')); - $select->where('entity_id = :entity_id'); - - return $this->getConnection()->fetchRow($select, ['entity_id' => $entityId]); - } - - /** - * Returns category path as array - * - * @param array $category - * @param array $path - * @return string - */ - protected function _getCategoryPath($category, $path = []) - { - $path[] = $category['entity_id']; - - if ($category['parent_id'] != 0) { - $parentCategory = $this->_getCategoryEntityRow($category['parent_id']); - if ($parentCategory) { - $path = $this->_getCategoryPath($parentCategory, $path); - } - } - - return $path; - } } diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 425044b2bdd626b6dea92862fe818cc8b1a239c4..485b7fd59268306cfad013b903526fb38c33e224 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -2008,5 +2008,10 @@ return [ ], ['getLinksConfig', 'Magento\Downloadable\Block\Catalog\Product\Links'], ['getAuthorizationAmounts', 'Magento\Paypal\Model\Config'], - ['cleanTransactions', 'Magento\Paypal\Model\Observer'] + ['cleanTransactions', 'Magento\Paypal\Model\Observer'], + ['compareIndexColumnProperties', 'Magento\Catalog\Model\Resource\Helper'], + ['getIsNullNotNullCondition', 'Magento\Catalog\Model\Resource\Helper'], + ['_getCategoryPath', 'Magento\Catalog\Model\Resource\Setup'], + ['_getCategoryEntityRow', 'Magento\Catalog\Model\Resource\Setup'], + ['createEavAttributeResource', 'Magento\Catalog\Model\Resource\Setup'], ]; diff --git a/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/SetupTest.php b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/SetupTest.php new file mode 100644 index 0000000000000000000000000000000000000000..557582b27a5035e74157f753fb8e472e895c14c7 --- /dev/null +++ b/dev/tests/unit/testsuite/Magento/Catalog/Model/Resource/SetupTest.php @@ -0,0 +1,107 @@ +<?php +/** + * @copyright Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com) + */ +namespace Magento\Catalog\Model\Resource; + +class SetupTest extends \PHPUnit_Framework_TestCase +{ + /** @var \Magento\Catalog\Model\Resource\Setup */ + protected $unit; + + protected function setUp() + { + $this->unit = (new \Magento\TestFramework\Helper\ObjectManager($this))->getObject( + 'Magento\Catalog\Model\Resource\Setup' + ); + } + + public function testGetDefaultEntitiesContainAllAttributes() + { + $defaultEntities = $this->unit->getDefaultEntities(); + + $this->assertEquals( + [ + 'name', + 'is_active', + 'description', + 'image', + 'meta_title', + 'meta_keywords', + 'meta_description', + 'display_mode', + 'landing_page', + 'is_anchor', + 'path', + 'position', + 'all_children', + 'path_in_store', + 'children', + 'custom_design', + 'custom_design_from', + 'custom_design_to', + 'page_layout', + 'custom_layout_update', + 'level', + 'children_count', + 'available_sort_by', + 'default_sort_by', + 'include_in_menu', + 'custom_use_parent_settings', + 'custom_apply_to_products', + 'filter_price_range', + ], + array_keys($defaultEntities['catalog_category']['attributes']) + ); + + $this->assertEquals( + [ + 'name', + 'sku', + 'description', + 'short_description', + 'price', + 'special_price', + 'special_from_date', + 'special_to_date', + 'cost', + 'weight', + 'manufacturer', + 'meta_title', + 'meta_keyword', + 'meta_description', + 'image', + 'small_image', + 'thumbnail', + 'media_gallery', + 'old_id', + 'group_price', + 'tier_price', + 'color', + 'news_from_date', + 'news_to_date', + 'gallery', + 'status', + 'minimal_price', + 'visibility', + 'custom_design', + 'custom_design_from', + 'custom_design_to', + 'custom_layout_update', + 'page_layout', + 'category_ids', + 'options_container', + 'required_options', + 'has_options', + 'image_label', + 'small_image_label', + 'thumbnail_label', + 'created_at', + 'updated_at', + 'country_of_manufacture', + 'quantity_and_stock_status', + ], + array_keys($defaultEntities['catalog_product']['attributes']) + ); + } +}