public function removeCategories($ids, $store_id = null) { $store_ids = Algolia_Algoliasearch_Helper_Entity_Helper::getStores($store_id); foreach ($store_ids as $store_id) { $index_name = $this->category_helper->getIndexName($store_id); $this->algolia_helper->deleteObjects($ids, $index_name); } }
public function getCategoryName($categoryId, $storeId = null) { if ($categoryId instanceof Mage_Catalog_Model_Category) { $categoryId = $categoryId->getId(); } if ($storeId instanceof Mage_Core_Model_Store) { $storeId = $storeId->getId(); } $categoryId = intval($categoryId); $storeId = intval($storeId); if (is_null(self::$_categoryNames)) { self::$_categoryNames = array(); $resource = Mage::getResourceModel('catalog/category'); /** @var $resource Mage_Catalog_Model_Resource_Category */ if ($attribute = $resource->getAttribute('name')) { /** @var Mage_Core_Model_Resource $coreResource */ $coreResource = Mage::getSingleton('core/resource'); $connection = $coreResource->getConnection('core_read'); $select = $connection->select()->from(array('backend' => $attribute->getBackendTable()), array(new Zend_Db_Expr("CONCAT(backend.store_id, '-', backend.entity_id)"), 'backend.value'))->join(array('category' => $resource->getTable('catalog/category')), 'backend.entity_id = category.entity_id', array())->where('backend.entity_type_id = ?', $attribute->getEntityTypeId())->where('backend.attribute_id = ?', $attribute->getAttributeId())->where('category.level > ?', 1); self::$_categoryNames = $connection->fetchPairs($select); } } $categoryName = null; $key = $storeId . '-' . $categoryId; if (isset(self::$_categoryNames[$key])) { // Check whether the category name is present for the specified store $categoryName = strval(self::$_categoryNames[$key]); } elseif ($storeId != 0) { // Check whether the category name is present for the default store $key = '0-' . $categoryId; if (isset(self::$_categoryNames[$key])) { $categoryName = strval(self::$_categoryNames[$key]); } } return $categoryName; }
public function removeCategories($ids, $store_id = null) { $store_ids = Algolia_Algoliasearch_Helper_Entity_Helper::getStores($store_id); foreach ($store_ids as $store_id) { if ($this->config->isEnabledBackEnd($store_id) === false) { $this->logger->log('INDEXING IS DISABLED FOR ' . $this->logger->getStoreName($store_id)); continue; } $index_name = $this->category_helper->getIndexName($store_id); $this->algolia_helper->deleteObjects($ids, $index_name); } }
public function rebuildProductIndex($storeId = null, $productIds = null) { $ids = Algolia_Algoliasearch_Helper_Entity_Helper::getStores($storeId); foreach ($ids as $id) { $by_page = $this->config->getNumberOfElementByPage(); if (is_array($productIds) && count($productIds) > $by_page) { foreach (array_chunk($productIds, $by_page) as $chunk) { $this->_rebuildProductIndex($id, $chunk); } } else { $this->_rebuildProductIndex($id, $productIds); } } return $this; }