Пример #1
0
 /**
  * Fixes CGI only one Status header allowed bug
  *
  * @link  http://bugs.php.net/bug.php?id=36705
  *
  */
 public function sendHeaders()
 {
     if (!$this->canSendHeaders()) {
         AO::log('HEADERS ALREADY SENT: ' . mageDebugBacktrace(true, true, true));
         return $this;
     }
     if (substr(php_sapi_name(), 0, 3) == 'cgi') {
         $statusSent = false;
         foreach ($this->_headersRaw as $i => $header) {
             if (stripos($header, 'status:') === 0) {
                 if ($statusSent) {
                     unset($this->_headersRaw[$i]);
                 } else {
                     $statusSent = true;
                 }
             }
         }
         foreach ($this->_headers as $i => $header) {
             if (strcasecmp($header['name'], 'status') === 0) {
                 if ($statusSent) {
                     unset($this->_headers[$i]);
                 } else {
                     $statusSent = true;
                 }
             }
         }
     }
     parent::sendHeaders();
 }
 public static function handlePhpError($errorCode, $errorMessage, $errorFile)
 {
     AO::log($errorMessage . $errorFile);
     if (in_array($errorCode, array(E_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR))) {
         $this->_fault('internal');
     }
     return true;
 }
 /**
  * Update tier prices of product
  *
  * @param int|string $productId
  * @param array $tierPrices
  * @return boolean
  */
 public function update($productId, $tierPrices)
 {
     AO::log($tierPrices);
     $product = $this->_initProduct($productId);
     if (!is_array($tierPrices)) {
         $this->_fault('data_invalid', AO::helper('catalog')->__('Invalid Tier Prices'));
     }
     $updateValue = array();
     foreach ($tierPrices as $tierPrice) {
         if (!is_object($tierPrice) || !isset($tierPrice->qty) || !isset($tierPrice->price)) {
             $this->_fault('data_invalid', AO::helper('catalog')->__('Invalid Tier Prices'));
         }
         if (!isset($tierPrice->website) || $tierPrice->website == 'all') {
             $tierPrice->website = 0;
         } else {
             try {
                 $tierPrice->website = AO::app()->getWebsite($tierPrice->website)->getId();
             } catch (Mage_Core_Exception $e) {
                 $tierPrice->website = 0;
             }
         }
         if (!isset($tierPrice->customer_group_id)) {
             $tierPrice->customer_group_id = 'all';
         }
         if ($tierPrice->customer_group_id == 'all') {
             $tierPrice->customer_group_id = Mage_Customer_Model_Group::CUST_GROUP_ALL;
         }
         $updateValue[] = array('website_id' => $tierPrice->website, 'cust_group' => $tierPrice->customer_group_id, 'price_qty' => $tierPrice->qty, 'price' => $tierPrice->price);
     }
     try {
         if (is_array($errors = $product->validate())) {
             $this->_fault('data_invalid', implode("\n", $errors));
         }
     } catch (Mage_Core_Exception $e) {
         $this->_fault('data_invalid', $e->getMessage());
     }
     try {
         $product->setData(self::ATTRIBUTE_CODE, $updateValue);
         $product->validate();
         $product->save();
     } catch (Mage_Core_Exception $e) {
         $this->_fault('not_updated', $e->getMessage());
     }
     return true;
 }
 /**
  * Print and/or log query
  *
  * @param boolean $printQuery
  * @param boolean $logQuery
  * @return  Mage_Sales_Model_Entity_Order_Attribute_Collection_Paid
  */
 public function printLogQuery($printQuery = false, $logQuery = false, $sql = null)
 {
     if ($printQuery) {
         echo is_null($sql) ? $this->getSelect()->__toString() : $sql;
     }
     if ($logQuery) {
         AO::log(is_null($sql) ? $this->getSelect()->__toString() : $sql);
     }
     return $this;
 }