Mage_Core_Model_Mysql4_Url_Rewrite_Collection Class Reference

Inheritance diagram for Mage_Core_Model_Mysql4_Url_Rewrite_Collection:

Mage_Core_Model_Mysql4_Collection_Abstract Varien_Data_Collection_Db Varien_Data_Collection

List of all members.

Public Member Functions

 addTagsFilter ($tags)
 addStoreFilter ($store, $withAdmin=true)
 filterAllByProductId ($productId)
 filterAllByCategory ()

Protected Member Functions

 _construct ()


Detailed Description

Definition at line 36 of file Collection.php.


Member Function Documentation

_construct (  )  [protected]

Initialization here

Reimplemented from Mage_Core_Model_Mysql4_Collection_Abstract.

Definition at line 38 of file Collection.php.

00039     {
00040         $this->_init('core/url_rewrite');
00041     }

addStoreFilter ( store,
withAdmin = true 
)

Filter collections by stores

Parameters:
mixed $store
bool $withAdmin
Returns:
Mage_Core_Model_Mysql4_Url_Rewrite_Collection

Definition at line 67 of file Collection.php.

00068     {
00069         if (is_array($store) || is_numeric($store)) {
00070             if (!is_array($store)) {
00071                 $store = array($store);
00072             }
00073         }
00074         else {
00075             $store = Mage::helper('core')->getStoreId($store);
00076         }
00077         if ($withAdmin) {
00078             $this->getSelect()->where('store_id = 0 OR store_id IN (?)', $store);
00079         }
00080         else {
00081             $this->getSelect()->where('store_id IN (?)', $store);
00082         }
00083         return $this;
00084     }

addTagsFilter ( tags  ) 

Add filter for tags (combined by OR)

Definition at line 46 of file Collection.php.

00047     {
00048         $tagsArr = is_array($tags) ? $tags : explode(',', $tags);
00049 
00050         $sqlArr = array();
00051         foreach ($tagsArr as $t) {
00052             $sqlArr[] = $this->getConnection()->quoteInto("find_in_set(?, `tags`)", $t);
00053         }
00054 
00055         $cond = $this->getConnection()->quoteInto('`url_rewrite_id`=main_table.`url_rewrite_id` and `tag` in (?)', $tagsArr);
00056         $this->getSelect()->join($this->getTable('url_rewrite_tag'), $cond, array());
00057         return $this;
00058     }

filterAllByCategory (  ) 

Definition at line 95 of file Collection.php.

00096     {
00097         $this->getSelect()
00098             ->where('id_path like ?', "category%");
00099         return $this;
00100     }

filterAllByProductId ( productId  ) 

Definition at line 86 of file Collection.php.

00087     {
00088         $this->getSelect()
00089             ->where('id_path = ?', "product/{$productId}")
00090             ->orWhere('id_path like ?', "product/{$productId}/%");
00091 
00092         return $this;
00093     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:59 2009 for Magento by  doxygen 1.5.8