/** * Enter description here ... * * @return Mage_Catalog_Model_Resource_Category_Flat_Collection */ public function addUrlRewriteToResult() { if (false === $this->_getFiHelper()->optimizeUrlRewriteFlatCategory()) { // code is the same in >1.7 return parent::addUrlRewriteToResult(); } // fastindexer removed the joinLeft() to table core_url_rewrite because data in flat table available! $this->getSelect()->columns('main_table.url_path as request_path'); //SchumacherFM_FastIndexer_Helper_Data::csdebug(__FILE__, __LINE__, $this->getSelect()); return $this; }
/** * Join url rewrite table to collection * * @param Mage_Catalog_Model_Resource_Category_Flat_Collection $collection * @param int $storeId * @return Mage_Catalog_Helper_Category_Url_Rewrite|Mage_Catalog_Helper_Category_Url_Rewrite_Interface */ public function joinTableToCollection(Mage_Catalog_Model_Resource_Category_Flat_Collection $collection, $storeId) { if ($this->_helper()->OptimizeCategoriesLeftJoin($storeId)) { $collection->getSelect()->joinLeft(array('url_rewrite' => $collection->getTable('urlindexer/url_rewrite')), 'url_rewrite.category_id = main_table.entity_id AND url_rewrite.is_system = 1 ' . ' AND ' . $collection->getConnection()->quoteInto('url_rewrite.store_id = ?', $storeId) . ' AND ' . $collection->getConnection()->quoteInto('url_rewrite.id_path LIKE ?', 'category/%'), array('request_path')); return $this; } return parent::joinTableToCollection($collection, $storeId); }
/** * Join url rewrite table to collection * * @param Mage_Catalog_Model_Resource_Category_Flat_Collection $collection * @param int $storeId * @return Mage_Catalog_Helper_Category_Url_Rewrite|Mage_Catalog_Helper_Category_Url_Rewrite_Interface */ public function joinTableToCollection(Mage_Catalog_Model_Resource_Category_Flat_Collection $collection, $storeId) { $collection->getSelect()->joinLeft(array('url_rewrite' => $collection->getTable('core/url_rewrite')), 'url_rewrite.category_id = main_table.entity_id AND url_rewrite.is_system = 1 ' . ' AND ' . $collection->getConnection()->quoteInto('url_rewrite.store_id = ?', $storeId) . ' AND ' . $collection->getConnection()->quoteInto('url_rewrite.id_path LIKE ?', 'category/%'), array('request_path')); return $this; }
/** * Join url rewrite table to flat collection * * @param Mage_Catalog_Model_Resource_Category_Flat_Collection $collection * @param int $storeId * @return Enterprise_Catalog_Helper_Category_UrlRewrite */ public function joinTableToCollection(Mage_Catalog_Model_Resource_Category_Flat_Collection $collection, $storeId) { $requestPath = $this->_connection->getIfNullSql('url_rewrite.request_path', 'default_ur.request_path'); $collection->getSelect()->joinLeft(array('url_rewrite_category' => $collection->getTable('enterprise_catalog/category')), 'url_rewrite_category.category_id = main_table.entity_id' . ' AND ' . $collection->getConnection()->quoteInto('url_rewrite_category.store_id = ?', $storeId), array(''))->joinLeft(array('url_rewrite' => $collection->getTable('enterprise_urlrewrite/url_rewrite')), 'url_rewrite_category.url_rewrite_id = url_rewrite.url_rewrite_id AND url_rewrite.is_system = 1', array(''))->joinLeft(array('default_urc' => $collection->getTable('enterprise_catalog/category')), 'default_urc.category_id = main_table.entity_id AND default_urc.store_id = 0', array(''))->joinLeft(array('default_ur' => $collection->getTable('enterprise_urlrewrite/url_rewrite')), 'default_ur.url_rewrite_id = default_urc.url_rewrite_id AND default_ur.is_system = 1', array('request_path' => $requestPath)); return $this; }
/** * Add index to category collection * * @param Mage_Catalog_Model_Resource_Category_Collection|Mage_Catalog_Model_Resource_Category_Flat_Collection $collection * @param int $customerGroupId * @param int $websiteId * @return Enterprise_CatalogPermissions_Model_Resource_Permission_Index */ public function addIndexToCategoryCollection($collection, $customerGroupId, $websiteId) { $adapter = $this->_getReadAdapter(); if ($collection instanceof Mage_Catalog_Model_Resource_Category_Flat_Collection) { $tableAlias = 'main_table'; } else { $tableAlias = 'e'; } $collection->getSelect()->joinLeft(array('permission_index' => $this->getTable('permission_index')), 'permission_index.category_id = ' . $tableAlias . '.entity_id' . ' AND ' . $adapter->quoteInto('permission_index.website_id = ?', $websiteId) . ' AND ' . $adapter->quoteInto('permission_index.customer_group_id = ?', $customerGroupId), array()); if (!Mage::helper('enterprise_catalogpermissions')->isAllowedCategoryView()) { $collection->getSelect()->where('permission_index.grant_catalog_category_view = ?', Enterprise_CatalogPermissions_Model_Permission::PERMISSION_ALLOW); } else { $collection->getSelect()->where('permission_index.grant_catalog_category_view != ?' . ' OR permission_index.grant_catalog_category_view IS NULL', Enterprise_CatalogPermissions_Model_Permission::PERMISSION_DENY); } return $this; }