Esempio n. 1
0
 /**
  * Delete action
  */
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (0 === (int) $id) {
         // No ID
         $this->_session->addError($this->__('Invalid entry ID.'));
         $this->_redirectBack();
         return;
     }
     try {
         /** @var $collection Mage_Oauth_Model_Resource_Token_Collection */
         $collection = Mage::getModel('oauth/token')->getCollection();
         $collection->joinConsumerAsApplication()->addFilterByCustomerId($this->_session->getCustomerId())->addFilterByType(Mage_Oauth_Model_Token::TYPE_ACCESS)->addFilterById($id);
         /** @var $model Mage_Oauth_Model_Token */
         $model = $collection->getFirstItem();
         if ($model->getId()) {
             $name = $model->getName();
             $model->delete();
             $this->_session->addSuccess($this->__('Application "%s" has been deleted.', $name));
         } else {
             $this->_session->addError($this->__('Application not found.'));
         }
     } catch (Mage_Core_Exception $e) {
         $this->_session->addError($e->getMessage());
     } catch (Exception $e) {
         $this->_session->addError($this->__('An error occurred on delete application.'));
         Mage::logException($e);
     }
     $this->_redirectBack();
 }
 /**
  * Instantiate current profile and put it into registry
  *
  * @return Mage_Sales_Model_Recurring_Profile
  * @throws Mage_Core_Exception
  */
 protected function _initProfile()
 {
     /** @var Mage_Sales_Model_Recurring_Profile $profile */
     $profile = Mage::getModel('sales/recurring_profile')->load($this->getRequest()->getParam('profile'));
     if (!$profile->getId() || $this->_session->getCustomerId() != $profile->getCustomerId()) {
         Mage::throwException($this->__('Specified profile does not exist.'));
     }
     Mage::register('current_recurring_profile', $profile);
     return $profile;
 }
Esempio n. 3
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;
 }