00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 class Mage_Core_Model_Mysql4_Url_Rewrite_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
00037 {
00038 protected function _construct()
00039 {
00040 $this->_init('core/url_rewrite');
00041 }
00042
00043
00044
00045
00046 public function addTagsFilter($tags)
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 }
00059
00060
00061
00062
00063
00064
00065
00066
00067 public function addStoreFilter($store, $withAdmin = true)
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 }
00085
00086 public function filterAllByProductId($productId)
00087 {
00088 $this->getSelect()
00089 ->where('id_path = ?', "product/{$productId}")
00090 ->orWhere('id_path like ?', "product/{$productId}/%");
00091
00092 return $this;
00093 }
00094
00095 public function filterAllByCategory()
00096 {
00097 $this->getSelect()
00098 ->where('id_path like ?', "category%");
00099 return $this;
00100 }
00101 }