diff --git a/CHANGELOG.md b/CHANGELOG.md index e61e2e1dd..fccd780dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # CHANGELOG +## 1.0.3 + +- Fixed issue with indexing content on Magento 2.1 EE and higher (#87) +- Fixed page indexing to index pages only from active stores (#82) + +## 1.0.2 + +- Fixed issue with merging JS files in administration - added new line at the end of [algoliaAdminBundle.min.js](https://github.com/algolia/algoliasearch-magento-2/blob/master/view/adminhtml/web/algoliaAdminBundle.min.js) + ## 1.0.1 - Fixed issue with merging JS files - added new line at the end of [algoliaBundle.min.js](https://github.com/algolia/algoliasearch-magento-2/blob/master/view/frontend/web/internals/algoliaBundle.min.js) diff --git a/Helper/ConfigHelper.php b/Helper/ConfigHelper.php index 20e9818b9..949592464 100755 --- a/Helper/ConfigHelper.php +++ b/Helper/ConfigHelper.php @@ -116,6 +116,11 @@ public function getMagentoVersion() return $this->productMetadata->getVersion(); } + public function getMagentoEdition() + { + return $this->productMetadata->getEdition(); + } + public function getExtensionVersion() { return $this->moduleResource->getDbVersion('Algolia_AlgoliaSearch'); diff --git a/Helper/Entity/BaseHelper.php b/Helper/Entity/BaseHelper.php index a07bf55cc..92a0d4ec7 100755 --- a/Helper/Entity/BaseHelper.php +++ b/Helper/Entity/BaseHelper.php @@ -48,6 +48,8 @@ abstract class BaseHelper protected $storeUrls; + private $idColumn; + abstract protected function getIndexNameSuffix(); public function __construct(Config $eavConfig, @@ -210,11 +212,11 @@ public function getCategories() if ($attribute = $resource->getAttribute('is_active')) { $connection = $this->queryResource->getConnection(); $select = $connection->select() - ->from(['backend' => $attribute->getBackendTable()], ['key' => new \Zend_Db_Expr("CONCAT(backend.store_id, '-', backend.entity_id)"), 'category.path', 'backend.value']) - ->join(['category' => $resource->getTable('catalog_category_entity')], 'backend.entity_id = category.entity_id', []) + ->from(['backend' => $attribute->getBackendTable()], ['key' => new \Zend_Db_Expr("CONCAT(backend.store_id, '-', backend.".$this->getCorrectIdColumn().")"), 'category.path', 'backend.value']) + ->join(['category' => $resource->getTable('catalog_category_entity')], 'backend.'.$this->getCorrectIdColumn().' = category.entity_id', []) ->where('backend.attribute_id = ?', $attribute->getAttributeId()) ->order('backend.store_id') - ->order('backend.entity_id'); + ->order('backend.'.$this->getCorrectIdColumn()); self::$_activeCategories = $connection->fetchAssoc($select); } @@ -246,8 +248,8 @@ public function getCategoryName($categoryId, $storeId = null) $connection = $this->queryResource->getConnection(); $select = $connection->select() - ->from(['backend' => $attribute->getBackendTable()], [new \Zend_Db_Expr("CONCAT(backend.store_id, '-', backend.entity_id)"), 'backend.value']) - ->join(['category' => $categoryModel->getTable('catalog_category_entity')], 'backend.entity_id = category.entity_id', []) + ->from(['backend' => $attribute->getBackendTable()], [new \Zend_Db_Expr("CONCAT(backend.store_id, '-', backend.".$this->getCorrectIdColumn().")"), 'backend.value']) + ->join(['category' => $categoryModel->getTable('catalog_category_entity')], 'backend.'.$this->getCorrectIdColumn().' = category.entity_id', []) ->where('backend.attribute_id = ?', $attribute->getAttributeId()) ->where('category.level > ?', 1); @@ -321,6 +323,21 @@ public function getStoreUrl($store_id) return $this->storeUrls[$store_id]; } - return; + return null; + } + + protected function getCorrectIdColumn() + { + if(isset($this->idColumn)) { + return $this->idColumn; + } + + $this->idColumn = 'entity_id'; + + if ($this->config->getMagentoEdition() !== 'Community' && version_compare($this->config->getMagentoVersion(), '2.1.0', '>=')) { + $this->idColumn = 'row_id'; + } + + return $this->idColumn; } } diff --git a/README.md b/README.md index 5be4d9c7a..c4fd8f3d2 100755 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ This extension replaces the default search of Magento with a typo-tolerant, fast See features and benefits of [Algolia Search Extension for Magento](https://community.algolia.com/magento). -![Latest version](https://img.shields.io/badge/latest-1.0.1-green.svg) +![Latest version](https://img.shields.io/badge/latest-1.0.3-green.svg) ![Magento 2.0.X](https://img.shields.io/badge/Magento-2.0.X-blue.svg) ![PHP >= 5.5.22](https://img.shields.io/badge/PHP-%3E=5.5.22-green.svg) diff --git a/composer.json b/composer.json index 33a8aeeeb..de6fad908 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "algolia/algoliasearch-magento-2", "description": "Algolia Search integration for Magento 2", "type": "magento2-module", - "version": "1.0.1", + "version": "1.0.3", "license": ["MIT"], "require": { "php": "~5.5.0|~5.6.0|~7.0.0", diff --git a/etc/module.xml b/etc/module.xml index bb92e088a..103cd9398 100755 --- a/etc/module.xml +++ b/etc/module.xml @@ -1,5 +1,5 @@ - + \ No newline at end of file