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 class Mage_Customer_Block_Account_Dashboard_Sidebar extends Mage_Core_Block_Template
00036 {
00037 protected $_cartItemsCount;
00038
00039
00040
00041
00042
00043
00044 protected $_wishlist;
00045
00046 protected $_compareItems;
00047
00048 public function getShoppingCartUrl()
00049 {
00050 return Mage::getUrl('checkout/cart');
00051 }
00052
00053 public function getCartItemsCount()
00054 {
00055 if( !$this->_cartItemsCount ) {
00056 $this->_cartItemsCount = Mage::getModel('sales/quote')
00057 ->setId(Mage::getModel('checkout/session')->getQuote()->getId())
00058 ->getItemsCollection()
00059 ->getSize();
00060 }
00061
00062 return $this->_cartItemsCount;
00063 }
00064
00065 public function getWishlist()
00066 {
00067 if( !$this->_wishlist ) {
00068 $this->_wishlist = Mage::getModel('wishlist/wishlist')
00069 ->loadByCustomer(Mage::getSingleton('customer/session')->getCustomer());
00070 $this->_wishlist->getItemCollection()
00071 ->addAttributeToSelect('name')
00072 ->addAttributeToSelect('price')
00073 ->addAttributeToSelect('small_image')
00074 ->addAttributeToFilter('store_id', array('in' => $this->_wishlist->getSharedStoreIds()))
00075 ->addAttributeToSort('added_at', 'desc')
00076 ->setCurPage(1)
00077 ->setPageSize(3)
00078 ->load();
00079 }
00080
00081 return $this->_wishlist->getItemCollection();
00082 }
00083
00084 public function getWishlistCount()
00085 {
00086 return $this->getWishlist()->getSize();
00087 }
00088
00089 public function getWishlistAddToCartLink($wishlistItem)
00090 {
00091 return Mage::getUrl('wishlist/index/cart', array('item' => $wishlistItem->getId()));
00092 }
00093
00094 public function getCompareItems()
00095 {
00096 if( !$this->_compareItems ) {
00097 $this->_compareItems = Mage::getResourceModel('catalog/product_compare_item_collection')
00098 ->setStoreId(Mage::app()->getStore()->getId());
00099 $this->_compareItems->setCustomerId(Mage::getSingleton('customer/session')->getCustomerId());
00100 $this->_compareItems
00101 ->addAttributeToSelect('name')
00102 ->useProductItem()
00103 ->load();
00104
00105 }
00106
00107 return $this->_compareItems;
00108 }
00109
00110 public function getCompareJsObjectName()
00111 {
00112 return "dashboardSidebarCompareJsObject";
00113 }
00114
00115 public function getCompareRemoveUrlTemplate()
00116 {
00117 return $this->getUrl('catalog/product_compare/remove',array('product'=>'#{id}'));
00118 }
00119
00120 public function getCompareAddUrlTemplate()
00121 {
00122 return $this->getUrl('catalog/product_compare/add',array('product'=>'#{id}'));
00123 }
00124
00125 public function getCompareUrl()
00126 {
00127 return $this->getUrl('catalog/product_compare');
00128 }
00129 }