Exemplo n.º 1
0
 public function processPendingEdits(&$edit, $sessionId = null, $checkIfExpired = false)
 {
     /* @var $db Mana_Db_Helper_Data */
     $db = Mage::helper('mana_db');
     if (!$edit) {
         $edit = mage::app()->getRequest()->getParam('edit');
     }
     if ($edit) {
         if (!is_array($edit)) {
             $edit = json_decode($edit, true);
         }
         if (!$sessionId) {
             $sessionId = $edit['sessionId'];
         }
         if (($checkIfExpired || count($edit['pending'])) && $db->isEditingSessionExpired($sessionId)) {
             throw new Mage_Core_Exception($db->__('Page editing session is expired. Please reload the page.'));
         }
         foreach ($edit['pending'] as $id => $cells) {
             if (isset($edit['deleted'][$id])) {
                 continue;
             }
             if (!($model = $this->loadEditedModel($id, $sessionId))) {
                 $model = $this->loadModel($id);
             } else {
                 $edit['saved'][$model->getEditStatus()] = $model->getId();
             }
             $isOriginal = false;
             if (!$model->getEditStatus()) {
                 $isOriginal = true;
                 $data = $model->getData();
                 $model = $this->createModel();
                 $status = $data['id'];
                 unset($data['id']);
                 $model->addData($data);
                 $model->setEditStatus($status)->setEditSessionId($edit['sessionId']);
             }
             $model->addGridCellData($cells);
             $model->save();
             if ($isOriginal) {
                 $edit['saved'][$id] = $model->getId();
             }
         }
         $edit['pending'] = array();
     }
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Return availability message
  *
  */
 public function getAvailabilityMessage()
 {
     $storeId = mage::app()->getStore()->getCode();
     return mage::helper('purchase/ProductAvailability')->getLabel($storeId, $this->getAverageSupplyDelay());
 }
 /**
  * Show availability description
  *
  * @param unknown_type $product
  */
 public function getDescription($product)
 {
     $retour = '';
     if (!$this->isInStock($product)) {
         if ($this->getSupplyDate($product) != null) {
             $retour = $this->__('Supply planed on ') . $this->getSupplyDate($product);
         } else {
             $storeId = mage::app()->getStore()->getCode();
             $retour = mage::helper('purchase/ProductAvailability')->getLabel($storeId, $product->getdefault_supply_delay());
         }
     }
     return $retour;
 }