Exemplo n.º 1
0
 public function __construct($order_id = null, $lang_id = null)
 {
     if ($lang_id !== NULL) {
         $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== FALSE ? (int) $lang_id : (int) JeproshopSettingModelSetting::getValue('default_lang');
     }
     if ($order_id) {
         $cache_id = 'jeproshop_order_model_' . $order_id . '_' . $lang_id . ($this->shop_id ? '_' . $this->shop_id : '');
         if (!JeproshopCache::isStored($cache_id)) {
             $db = JFactory::getDBO();
             $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord ";
             $where = "";
             /** get language information **/
             if ($lang_id) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_order_lang') . " AS order_lang ";
                 $query .= " ON (ord.order_id = order_lang.order_id AND order_lang.lang_id = " . (int) $lang_id . ") ";
                 if ($this->shop_id && !empty($this->multiLangShop)) {
                     $where = " AND order_lang.shop_id = " . $this->shop_id;
                 }
             }
             /** Get shop informations **/
             if (JeproshopShopModelShop::isTableAssociated('order')) {
                 $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_order_shop') . " AS order_shop ON (";
                 $query .= "ord.order_id = order_shop.order_id AND order_shop.shop_id = " . (int) $this->shop_id . ")";
             }
             $query .= " WHERE ord.order_id = " . (int) $order_id . $where;
             $db->setQuery($query);
             $order_data = $db->loadObject();
             if ($order_data) {
                 JeproshopCache::store($cache_id, $order_data);
             }
         } else {
             $order_data = JeproshopCache::retrieve($cache_id);
         }
         if ($order_data) {
             $order_data->order_id = $order_id;
             foreach ($order_data as $key => $value) {
                 if (property_exists($key, $this)) {
                     $this->{$key} = $value;
                 }
             }
         }
     }
     $this->_taxCalculationMethod = JeproshopGroupModelGroup::getDefaultPriceDisplayMethod();
 }