diff --git a/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Resource/Indexer/Abstract.php b/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Resource/Indexer/Abstract.php index d625420..2c22f78 100644 --- a/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Resource/Indexer/Abstract.php +++ b/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Resource/Indexer/Abstract.php @@ -59,6 +59,13 @@ abstract class Netzarbeiter_GroupsCatalog2_Model_Resource_Indexer_Abstract exten */ protected $_groupIds = array(); + /** + * Array of assigned category products + * + * @var array $_categoryProducts + */ + protected $_categoryProducts = array(); + /** * Module helper instance * @@ -325,6 +332,8 @@ protected function _insertIndexRecords(Zend_Db_Statement $stmt, array $limitToGr $data, $entityId, $entityDefaultGroupsWithoutMode, $storesHandled, $limitToGroupIds ); + $this->_applyFilterToData($data); + // Insert INSERT_CHUNK_SIZE records at a time. // If INSERT_CHUNK_SIZE records exist in $data then it is reset to an empty array afterwards $this->_insertIndexRecordsIfMinChunkSizeReached($data, self::INSERT_CHUNK_SIZE); @@ -365,6 +374,7 @@ protected function _insertIndexRecords(Zend_Db_Statement $stmt, array $limitToGr $data, $entityId, $entityDefaultGroupsWithoutMode, $storesHandled, $limitToGroupIds ); + $this->_applyFilterToData($data); // Insert missing index records $this->_insertIndexRecordsIfMinChunkSizeReached($data, 1); } @@ -372,6 +382,16 @@ protected function _insertIndexRecords(Zend_Db_Statement $stmt, array $limitToGr Varien_Profiler::stop($this->_getProfilerName() . '::reindexEntity::insert'); } + /** + * Apply a filter + * + * @param array $data Insert data + */ + protected function _applyFilterToData(array &$data) + { + + } + /** * Add a record to the data array if the group Id was not excluded by $limitToGroupIds * diff --git a/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Resource/Indexer/Category.php b/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Resource/Indexer/Category.php index ac255d2..26c4e70 100644 --- a/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Resource/Indexer/Category.php +++ b/app/code/community/Netzarbeiter/GroupsCatalog2/Model/Resource/Indexer/Category.php @@ -68,4 +68,40 @@ protected function _getEntityTypeCode() { return Mage_Catalog_Model_Category::ENTITY; } + + /** + * Apply a filter + * + * @param array $data Insert data + */ + protected function _applyFilterToData(array &$data) + { + if ($this->_helper()->getConfig('show_empty_categories')) return; + + $this->_categoryProducts = array(); + foreach($data as $key => $values) { + $visibleItems = array(); + if(empty($this->_categoryProducts[$values['catalog_entity_id']])) { + $this->_categoryProducts[$values['catalog_entity_id']] = array(); + $category = Mage::getModel('catalog/category')->load($values['catalog_entity_id']); + $productCollection = Mage::getResourceModel('catalog/product_collection') + ->addCategoryFilter($category); + foreach($productCollection as $product) { + $this->_categoryProducts[$values['catalog_entity_id']][] = $product->getId(); + } + } + if(!empty($this->_categoryProducts[$values['catalog_entity_id']])) { + $visibleItems = Mage::getResourceSingleton('netzarbeiter_groupscatalog2/filter') + ->getVisibleIdsFromEntityIdList( + Mage_Catalog_Model_Product::ENTITY, + $this->_categoryProducts[$values['catalog_entity_id']], + $values['store_id'], + $values['group_id'] + ); + } + if(empty($visibleItems)) { + unset($data[$key]); + } + } + } } diff --git a/app/code/community/Netzarbeiter/GroupsCatalog2/etc/config.xml b/app/code/community/Netzarbeiter/GroupsCatalog2/etc/config.xml index a1cc317..ebf2857 100644 --- a/app/code/community/Netzarbeiter/GroupsCatalog2/etc/config.xml +++ b/app/code/community/Netzarbeiter/GroupsCatalog2/etc/config.xml @@ -281,6 +281,7 @@ 404 customer/account/login cms + 1 0 Please register an account and log in. Please contact us to request further access privileges. diff --git a/app/code/community/Netzarbeiter/GroupsCatalog2/etc/system.xml b/app/code/community/Netzarbeiter/GroupsCatalog2/etc/system.xml index ee53887..e745640 100644 --- a/app/code/community/Netzarbeiter/GroupsCatalog2/etc/system.xml +++ b/app/code/community/Netzarbeiter/GroupsCatalog2/etc/system.xml @@ -192,6 +192,19 @@ 302 + + + select + adminhtml/system_config_source_yesno + 95 + 1 + 1 + 1 + + + 1 + + select diff --git a/app/locale/de_DE/Netzarbeiter_GroupsCatalog2.csv b/app/locale/de_DE/Netzarbeiter_GroupsCatalog2.csv index 652076a..99ea3aa 100644 --- a/app/locale/de_DE/Netzarbeiter_GroupsCatalog2.csv +++ b/app/locale/de_DE/Netzarbeiter_GroupsCatalog2.csv @@ -43,4 +43,5 @@ "Show multiselect customer group fields","Kundengruppen Multiselect Felder im Backend anzeigen" "Disable only if there is a very large number of customer groups and if the product and category settings are done using some import mechanism instead of the admin panel.","Nur deaktivieren wenn es sehr viele Kundengruppen gibt und die Produkt- und Kategorie-Einstellungen mittels eines Import Mechanismus gesetzt werden anstelle des Admin-Interfaces." "This field is read-only.
(change the ""Show multiselect customer group fields"" option further down to enable this field)","Dieses Feld kann nur gelesen werden.
(ändern Sie ""Kundengruppen Multiselect Felder im Backend anzeigen"" um es zu aktivieren)" - +"Should empty categories shown in Frontend-Menu?","Sollen leere Kategorien im Menü erscheinen?" +"Please reindex the category index after change","Bitte nach Änderung den GroupsCatalog Kategorien index neu erstellen"