Esempio n. 1
0
 /**
  * Calculate cache product compare collection
  *
  * @param  bool $logout
  * @return Mage_Catalog_Helper_Product_Compare
  */
 public function calculate($logout = false)
 {
     // first visit
     if (!$this->_catalogSession->hasCatalogCompareItemsCount() && !$this->_customerId) {
         $count = 0;
     } else {
         /** @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Compare_Item_Collection */
         $collection = Mage::getResourceModel('catalog/product_compare_item_collection')->useProductItem(true);
         if (!$logout && $this->_customerSession->isLoggedIn()) {
             $collection->setCustomerId($this->_customerSession->getCustomerId());
         } elseif ($this->_customerId) {
             $collection->setCustomerId($this->_customerId);
         } else {
             $collection->setVisitorId($this->_logVisitor->getId());
         }
         /* Price data is added to consider item stock status using price index */
         $collection->addPriceData();
         $this->_productVisibility->addVisibleInSiteFilterToCollection($collection);
         $count = $collection->getSize();
     }
     $this->_catalogSession->setCatalogCompareItemsCount($count);
     return $this;
 }
 /**
  * Determine the path to redirect to based on customer logging status.
  *
  * @param  Mage_Customer_Model_Session
  * @return string
  */
 protected function _getRomReturnPath(Mage_Customer_Model_Session $session)
 {
     return $session->isLoggedIn() ? static::LOGGED_IN_ORDER_HISTORY_PATH : static::GUEST_ORDER_FORM_PATH;
 }
 /**
  * return the last login time as a DateTime object.
  * return null if the last login time cannot be calculated.
  * @param  Mage_Customer_Model_Session
  * @param  Mage_Log_Model_Visitor
  * @return DateTime
  */
 protected function _getLastLoginTime(Mage_Customer_Model_Session $session, Mage_Log_Model_Visitor $visitorLog = null)
 {
     if ($visitorLog && $session->isLoggedIn()) {
         $lastLogin = date_create_from_format(self::MAGE_DATETIME_FORMAT, $this->_customerLog->load($visitorLog->getId(), 'visitor_id')->getLoginAt());
     }
     return isset($lastLogin) ? $lastLogin : null;
 }