Public Member Functions | |
getListUrl () | |
getAddUrl ($product) | |
getAddToWishlistUrl ($product) | |
getAddToCartUrl ($product) | |
getRemoveUrl ($item) | |
getClearListUrl () | |
getItemCollection () | |
calculate () | |
getItemCount () | |
hasItems () | |
setAllowUsedFlat ($flag) | |
getAllowUsedFlat () | |
Protected Member Functions | |
_getUrlParams ($product) | |
Protected Attributes | |
$_itemCollection | |
$_hasItems | |
$_allowUsedFlat = true |
Definition at line 35 of file Compare.php.
_getUrlParams | ( | $ | product | ) | [protected] |
Get parameters used for build add product to compare list urls
Mage_Catalog_Model_Product | $product |
Definition at line 84 of file Compare.php.
00085 { 00086 return array( 00087 'product' => $product->getId(), 00088 Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl() 00089 ); 00090 }
calculate | ( | ) |
Calculate cache product compare collection
Definition at line 200 of file Compare.php.
00201 { 00202 if (!Mage::getSingleton('customer/session')->isLoggedIn() 00203 and !Mage::getSingleton('log/visitor')->hasCatalogCompareItemsCount() 00204 ) { 00205 Mage::getSingleton('log/visitor')->setCatalogCompareItemsCount(0); 00206 return $this; 00207 } 00208 00209 $itemCollection = Mage::getResourceModel('catalog/product_compare_item_collection'); 00210 /* @var $itemCollection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Compare_Item_Collection */ 00211 $itemCollection->setStoreId(Mage::app()->getStore()->getId()); 00212 if (Mage::getSingleton('customer/session')->isLoggedIn()) { 00213 $itemCollection->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId()); 00214 } 00215 else { 00216 $itemCollection->setVisitorId(Mage::getSingleton('log/visitor')->getId()); 00217 } 00218 Mage::getSingleton('catalog/product_visibility') 00219 ->addVisibleInSiteFilterToCollection($itemCollection); 00220 00221 Mage::getSingleton('log/visitor')->setCatalogCompareItemsCount($itemCollection->getSize()); 00222 return $this; 00223 }
getAddToCartUrl | ( | $ | product | ) |
Retrive add to cart url
Mage_Catalog_Model_Product | $product |
Definition at line 127 of file Compare.php.
00128 { 00129 $beforeCompareUrl = Mage::getSingleton('catalog/session')->getBeforeCompareUrl(); 00130 $params = array( 00131 'product'=>$product->getId(), 00132 Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl($beforeCompareUrl) 00133 ); 00134 00135 return $this->_getUrl('checkout/cart/add', $params); 00136 }
getAddToWishlistUrl | ( | $ | product | ) |
Retrive add to wishlist url
Mage_Catalog_Model_Product | $product |
Definition at line 109 of file Compare.php.
00110 { 00111 $beforeCompareUrl = Mage::getSingleton('catalog/session')->getBeforeCompareUrl(); 00112 00113 $params = array( 00114 'product'=>$product->getId(), 00115 Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl($beforeCompareUrl) 00116 ); 00117 00118 return $this->_getUrl('wishlist/index/add', $params); 00119 }
getAddUrl | ( | $ | product | ) |
Retrieve url for adding product to conpare list
Mage_Catalog_Model_Product | $product |
Definition at line 98 of file Compare.php.
00099 { 00100 return $this->_getUrl('catalog/product_compare/add', $this->_getUrlParams($product)); 00101 }
getAllowUsedFlat | ( | ) |
Retrieve is allow used flat (for collection)
Definition at line 265 of file Compare.php.
getClearListUrl | ( | ) |
Retrieve clear compare list url
Definition at line 158 of file Compare.php.
00159 { 00160 $params = array( 00161 Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl() 00162 ); 00163 return $this->_getUrl('catalog/product_compare/clear', $params); 00164 }
getItemCollection | ( | ) |
Retrieve compare list items collection
Definition at line 171 of file Compare.php.
00172 { 00173 if (!$this->_itemCollection) { 00174 $this->_itemCollection = Mage::getResourceModel('catalog/product_compare_item_collection') 00175 ->useProductItem(true) 00176 ->setStoreId(Mage::app()->getStore()->getId()); 00177 00178 if (Mage::getSingleton('customer/session')->isLoggedIn()) { 00179 $this->_itemCollection->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId()); 00180 } 00181 else { 00182 $this->_itemCollection->setVisitorId(Mage::getSingleton('log/visitor')->getId()); 00183 } 00184 00185 Mage::getSingleton('catalog/product_visibility')->addVisibleInSiteFilterToCollection($this->_itemCollection); 00186 00187 $this->_itemCollection->addAttributeToSelect('name') 00188 ->addUrlRewrite() 00189 ->load(); 00190 } 00191 00192 return $this->_itemCollection; 00193 }
getItemCount | ( | ) |
Retrieve count of items in compare list
Definition at line 230 of file Compare.php.
00231 { 00232 if (is_null(Mage::getSingleton('log/visitor')->getCatalogCompareItemsCount())) { 00233 $this->calculate(); 00234 } 00235 return Mage::getSingleton('log/visitor')->getCatalogCompareItemsCount(); 00236 }
getListUrl | ( | ) |
Retrieve compare list url
Definition at line 63 of file Compare.php.
00064 { 00065 $itemIds = array(); 00066 foreach ($this->getItemCollection() as $item) { 00067 $itemIds[] = $item->getId(); 00068 } 00069 00070 $params = array( 00071 'items'=>implode(',', $itemIds), 00072 Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl() 00073 ); 00074 00075 return $this->_getUrl('catalog/product_compare', $params); 00076 }
getRemoveUrl | ( | $ | item | ) |
Retrieve remove item from compare list url
$item |
Definition at line 144 of file Compare.php.
00145 { 00146 $params = array( 00147 'product'=>$item->getId(), 00148 Mage_Core_Controller_Front_Action::PARAM_NAME_URL_ENCODED => $this->getEncodedUrl() 00149 ); 00150 return $this->_getUrl('catalog/product_compare/remove', $params); 00151 }
hasItems | ( | ) |
Check has items
Definition at line 243 of file Compare.php.
00244 { 00245 return $this->getItemCount() > 0; 00246 }
setAllowUsedFlat | ( | $ | flag | ) |
Set is allow used flat (for collection)
bool | $flag |
Definition at line 254 of file Compare.php.
$_allowUsedFlat = true [protected] |
Definition at line 56 of file Compare.php.
$_hasItems [protected] |
Definition at line 49 of file Compare.php.
$_itemCollection [protected] |
Definition at line 42 of file Compare.php.