public function __construct($address_id = NULL, $lang_id = NULL) { if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== FALSE ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($address_id) { //Load address from database if address id is provided $cache_id = 'jeproshop_address_model_' . $address_id . '_' . $lang_id; if (!JeproshopCache::isStored($cache_id)) { $db = JFactory::getDBO(); $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_address') . " AS address "; $query .= " WHERE address.address_id = " . (int) $address_id; $db->setQuery($query); $address_data = $db->loadObject(); if ($address_data) { JeproshopCache::store($cache_id, $address_data); } } else { $address_data = JeproshopCache::retrieve($cache_id); } if ($address_data) { $address_data->address_id = $address_id; foreach ($address_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } if ($this->address_id) { $this->country = JeproshopCountryModelCountry::getNameById($lang_id, $this->country_id); } }
public function __construct($country_id = null, $lang_id = null, $shop_id = NULL) { $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->get_shop_from_context = FALSE; } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($country_id) { $cache_id = 'jeproshop_country_model_' . (int) $country_id . '_' . (int) $lang_id . '_' . (int) $shop_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_country') . " AS country "; //Get language data if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_country_lang') . " AS country_lang ON (country_lang." . $db->quoteName('country_id') . " = country." . $db->quoteName('country_id') . " AND country_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")"; } if (JeproshopShopModelShop::isTableAssociated('country')) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_country_shop') . " AS country_shop ON (country_shop." . $db->quoteName('country_id') . " = country." . $db->quoteName('country_id') . " AND country_shop." . $db->quoteName('shop_id') . " = " . (int) $shop_id . ") "; } $db->setQuery($query); $country_data = $db->loadObject(); if ($country_data) { if (!$lang_id) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_country_lang') . " WHERE " . $db->quoteName('country_id') . " = " . (int) $country_id; $db->setQuery($query); $country_lang_data = $db->loadObjectList(); if ($country_lang_data) { foreach ($country_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'country_id') { if (!isset($country_data->{$key}) || !is_array($country_data->{$key})) { $country_data->{$key} = array(); } $country_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $country_data); } } else { $country_data = JeproshopCache::retrieve($cache_id); } if ($country_data) { $country_data->country_id = (int) $country_id; foreach ($country_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } }
public function __construct($manufacturer_id = null, $lang_id = null) { $db = JFactory::getDBO(); if ($lang_id !== null) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== false ? $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($manufacturer_id) { // Load object from database if object id is present $cache_id = 'jeproshop_manufacturer_model_' . (int) $manufacturer_id . '_' . (int) $lang_id; $db = JFactory::getDBO(); if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_manufacturer') . " AS manufacturer "; // Get lang informations if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_manufacturer_lang') . " AS manufacturer_lang ON (manufacturer." . $db->quoteName('manufacturer_id'); $query .= " = manufacturer_lang." . $db->quoteName('manufacturer_id') . " AND manufacturer_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")"; } $query .= " WHERE manufacturer." . $db->quoteName('manufacturer_id') . " = " . (int) $manufacturer_id; // Get shop informations /*if (Shop::isTableAssociated($this->def['table'])) $sql->leftJoin($this->def['table'].'_shop', 'c', 'a.'.$this->def['primary'].' = c.'.$this->def['primary'].' AND c.id_shop = '.(int)$this->id_shop); */ $db->setQuery($query); $manufacturer_data = $db->loadObject(); if ($manufacturer_data) { if (!$lang_id) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_manufacturer_lang') . " WHERE " . $db->quoteName('manufacturer_id') . " = " . (int) $manufacturer_id; $db->setQuery($query); $manufacturer_data_lang = $db->loadObjectList(); if ($manufacturer_data_lang) { foreach ($manufacturer_data_lang as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'manufacturer_id') { if (!isset($manufacturer_data->{$key}) || !is_array($manufacturer_data->{$key})) { $manufacturer_data->{$key} = array(); } $manufacturer_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $manufacturer_data); } } else { $manufacturer_data = JeproshopCache::retrieve($cache_id); } if ($manufacturer_data) { //$this->id = (int)$id; foreach ($manufacturer_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } $this->link_rewrite = JeproshopTools::str2url($this->name); }
public function __construct($tax_id = null, $lang_id = null) { $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($tax_id) { $cache_id = 'jeproshop_tax_model_' . $tax_id . '_' . $lang_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_tax') . " AS tax "; if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_tax_lang') . " AS tax_lang ON (tax." . $db->quoteName('tax_id') . " = tax_lang." . $db->quoteName('lang_id') . " AND tax_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") "; } $query .= " WHERE tax." . $db->quoteName('tax_id') . " = " . (int) $tax_id; $db->setQuery($query); $tax_data = $db->loadObject(); if ($tax_data) { if (!$lang_id) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_tax_lang') . " WHERE " . $db->quoteName('tax_id') . " = " . (int) $tax_id; $db->setQuery($query); $tax_lang_data = $db->loadObjectList(); foreach ($tax_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'tax_id') { if (!isset($tax_data->{$key}) || !is_array($tax_data->{$key})) { $tax_data->{$key} = array(); } $tax_data->{$key}[$row->lang_id] = $value; } } } } JeproshopCache::store($cache_id, $tax_data); } } else { $tax_data = JeproshopCache::retrieve($cache_id); } if ($tax_data) { $tax_data->tax_id = $tax_id; foreach ($tax_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } }
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(); }
public function __construct($cart_id = null, $lang_id = null) { $db = JFactory::getDBO(); if (!is_null($lang_id)) { $this->lang_id = (int) (JeproshopLanguageModelLanguage::getLanguage($lang_id) !== false) ? $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($cart_id) { //Load object from database if object $cache_id = 'jeproshop_cart_model_cart_' . $cart_id . '_' . $lang_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_cart') . " AS cart WHERE " . $db->quoteName('cart_id') . " = " . (int) $lang_id; $db->setQuery($query); $cartData = $db->loadObject(); if ($cartData) { JeproshopCache::store($cache_id, $cartData); } } else { $cartData = JeproshopCache::retrieve($cache_id); } if ($cartData) { $this->cart_id = (int) $cart_id; foreach ($cartData as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } print_r($cartData); } if ($this->customer_id) { if (isset(JeproshopContext::getContext()->customer) && JeproshopContext::getContext()->customer->customer_id == $this->customer_id) { $customer = JeproshopContext::getContext()->customer; } else { $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id); } if ((!$this->secure_key || $this->secure_key == '-1') && $customer->secure_key) { $this->secure_key = $customer->secure_key; $this->save(); } } $this->_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod(JeproshopGroupModelGroup::getCurrent()->group_id); }
public function __construct($shop_id = NULL, $lang_id = NULL) { parent::__construct(); $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) != FALSE ? $lang_id : JeproshopSettingModelSetting::getSettingValue('default_lang'); } if ($shop_id) { $this->shop_id = (int) $shop_id; $this->get_shop_from_context = FALSE; } if (!$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($shop_id) { //load object from database if object id is present $cache_id = 'jeproshop_shop_model_' . $shop_id . '_' . $lang_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_shop') . " AS shop "; $where = ""; if ($lang_id) { //Get lang informations $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_shop_lang') . " AS shop_lang "; $query .= " ON (shop.shop_id = shop_lang.shop_id AND shop_lang.lang_id = " . (int) $lang_id . ")"; if ($this->shop_id && !empty($this->multiLangShop)) { $where = " AND shop_lang.shop_id = " . $this->shop_id; } } $query .= "WHERE shop.shop_id = " . (int) $shop_id . $where; $db->setQuery($query); $shop_data = $db->loadObject(); if ($shop_data) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_shop_lang') . " WHERE shop_id = " . (int) $shop_id; $db->setQuery($query); $shop_lang_data = $db->loadObjectList(); if ($shop_lang_data) { foreach ($shop_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'shop_id') { if (!isset($shop_data->{$key}) || !is_array($shop_data->{$key})) { $shop_data->{$key} = array(); } $shop_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $shop_data); } } else { $shop_data = JeproshopCache::retrieve($cache_id); } if ($shop_data) { $shop_data->shop_id = (int) $shop_id; foreach ($shop_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } if ($this->shop_id) { $this->setShopUrl(); } }
public function __construct($group_id = NULL, $lang_id = NULL, $shop_id = NULL) { $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->getShopFromContext = FALSE; } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($group_id) { $cache_id = 'jeproshop_group_model_' . $group_id . '_' . $lang_id . '_' . $shop_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_group') . " AS j_group "; $where = ""; /** get language information **/ if ($lang_id) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_group_lang') . " AS group_lang "; $query .= "ON (j_group.group_id = group_lang.group_id AND group_lang.lang_id = " . (int) $lang_id . ") "; if ($this->shop_id && !empty($this->multiLangShop)) { $where = " AND group_lang.shop_id = " . $this->shop_id; } } /** Get shop informations **/ if (JeproshopShopModelShop::isTableAssociated('group')) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_group_shop') . " AS group_shop ON ("; $query .= "j_group.group_id = group_shop.group_id AND group_shop.shop_id = " . (int) $this->shop_id . ")"; } $query .= " WHERE j_group.group_id = " . (int) $group_id . $where; $db->setQuery($query); $group_data = $db->loadObject(); if ($group_data) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_group_lang'); $query .= " WHERE group_id = " . (int) $group_id; $db->setQuery($query); $group_lang_data = $db->loadObjectList(); if ($group_lang_data) { foreach ($group_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'group_id') { if (!isset($group_data->{$key}) || !is_array($group_data->{$key})) { $group_data->{$key} = array(); } $group_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $group_data); } } else { $group_data = JeproshopCache::retrieve($cache_id); } if ($group_data) { $group_data->group_id = $group_id; foreach ($group_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } if ($this->group_id && !isset(JeproshopGroupModelGroup::$group_price_display_method[$this->group_id])) { self::$group_price_display_method[$this->group_id] = $this->price_display_method; } }
/** Get cookie content **/ public function update() { $cookie = JRequest::get('COOKIE'); if (isset($cookie[$this->_name])) { /** Decrypt cookie content **/ $content = $this->_cipherTool->decrypt($cookie[$this->_name]); /** Get cookie checksum **/ $checksum = crc32($this->_iv . substr($content, 0, strrpos($content, '�') + 2)); /** Un-serialize cookie content **/ $tmpTab = explode('�', $content); foreach ($tmpTab as $keyAndValue) { $tmpTab2 = explode('|', $keyAndValue); if (count($tmpTab2) == 2) { $this->_content[$tmpTab2[0]] = $tmpTab2[1]; } } /** Blowfish fix **/ if (isset($this->_content['checksum'])) { $this->_content['checksum'] = (int) $this->_content['checksum']; } /** Check if cookie has not been modified **/ if (!isset($this->_content['checksum']) || $this->_content['checksum'] != $checksum) { $this->logOut(); } if (!isset($this->_content['date_add'])) { $this->_content['date_add'] = date('Y-m-d H:i:s'); } } else { $this->_content['date_add'] = date('Y-m-d H:i:s'); } /** checks if the language exists , if not choose the default language **/ if (!JeproshopLanguageModelLanguage::getLanguage((int) $this->lang_id)) { $this->lang_id = JeproshopSettingModelSetting::getValue('default_lang'); } }
public function __construct($shop_id = null, $lang_id = null) { parent::__construct(); $db = JFactory::getDBO(); if ($lang_id != null) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) != false ? $lang_id : JeproshopSettingModelSetting::getSettingValue('default_lang'); } if ($shop_id) { /** Load shop from database if id is supplied */ $cache_id = 'jeproshop_shop_model_' . (int) $shop_id . ($lang_id > 0 ? '_' . $lang_id : ''); if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_shop') . " AS shop "; if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_shop_lang'); $query .= " ON(shop." . $db->quoteName('shop_id') . " = shop_lang." . $db->quoteName('shop_id'); $query .= " AND shop_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")"; } $query .= " WHERE shop." . $db->quoteName('shop_id') . " = " . (int) $shop_id; $db->setQuery($query); $shop_data = $db->loadObject(); //print_r($shop_data); if ($shop_data) { /*if($lang_id && isset($this->multilang) && $this->multilang){ $query = " SELECT * FROM " . $db->quoteName('#__jeproshop_shop_lang') . " WHERE "; $query .= $db->quoteName('shop_id') . " = " . $shop_id; $db->setQuery($query); $shop_lang_data = $db->loadObjectList(); if($shop_lang_data){ foreach($shop_lang_data as $row){ foreach($row as $key => $value){ if(array_key_exists($key, $this) && $key != 'shop_id'){ if(!isset($shop_data->{$key}) || !is_array($shop_data->{$key})){ $shop_data->{$key} = array(); } $shop_data->{$key}[$row->lang_id] = $value; } } } } }*/ JeproshopCache::store($cache_id, $shop_data); } } else { $shop_data = JeproshopCache::retrieve($cache_id); } if ($shop_data) { $this->shop_id = (int) $shop_id; foreach ($shop_data as $key => $value) { if (array_key_exists($key, $this)) { //if($key != 'name'){ $this->{$key} = $value; /*}else{ $prop = 'shop_' . $key; $this->{$prop} = $value; }*/ } } } } if ($this->shop_id) { $this->setShopUrl(); } }
public function __construct($attribute_group_id = null, $lang_id = null, $shop_id = null) { if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== FALSE ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->get_shop_from_context = false; } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($attribute_group_id) { $cache_id = 'jeproshop_attribute_group_model_' . (int) $attribute_group_id; if (!JeproshopCache::isStored($cache_id)) { $db = JFactory::getDBO(); $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_attribute_group') . " AS attribute_group "; $where = " WHERE attribute_group." . $db->quoteName('attribute_group_id') . " = " . (int) $attribute_group_id; //Get Language information if ($lang_id) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_attribute_group_lang') . " AS attribute_group_lang ON (attribute_group."; $query .= $db->quoteName('attribute_group_id') . " = attribute_group_lang." . $db->quoteName('attribute_group_id') . " AND "; $query .= "attribute_group_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ")"; if ($this->shop_id && !empty($this->multiLangShop)) { $where .= " AND attribute_group_lang." . $db->quoteName('shop_id') . " = " . (int) $shop_id; } } // Get Shop Information if (JeproshopShopModelShop::isTableAssociated('attribute_group')) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_attribute_group_shop') . " AS attribute_group_shop ON (attribute_group."; $query .= $db->quoteName('attribute_group_id') . " = attribute_group_shop." . $db->quoteName('attribute_group_id') . " AND attribute_group_shop."; $query .= $db->quoteName('shop_id') . " = " . (int) $this->shop_id . ")"; } $db->setQuery($query . $where); $attributeGroupData = $db->loadObject(); if ($attributeGroupData) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_attribute_group_lang') . " WHERE " . $db->quoteName('attribute_group_id') . " = "; $query .= (int) $attribute_group_id; // . (($this->shop_id && $this->isMultiLangShop()) ? " AND " . $db->quoteName('shop_id') . " = " . (int)$this->shop_id : ""); $db->setQuery($query); $attributeGroupDataLang = $db->loadObjectList(); if ($attributeGroupDataLang) { foreach ($attributeGroupDataLang as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'attribute_group_id') { if (!isset($attributeGroupData->{$key}) || !is_array($attributeGroupData->{$key})) { $attributeGroupData->{$key} = array(); } $attributeGroupData->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $attributeGroupData); } } else { $attributeGroupData = JeproshopCache::retrieve($cache_id); } if ($attributeGroupData) { $this->attribute_group_id = (int) $attribute_group_id; foreach ($attributeGroupData as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } }
public function __construct($carrier_id = null, $lang_id = null) { $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($carrier_id) { $cache_id = 'jeproshop_carrier_model_' . $carrier_id . '_' . $lang_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_carrier') . " AS carrier "; $where = ""; /** get language information **/ if ($lang_id) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_carrier_lang') . " AS carrier_lang ON (carrier."; $query .= "carrier_id = carrier_lang.carrier_id AND carrier_lang.lang_id = " . (int) $lang_id . ") "; /*if($this->shop_id && !(empty($this->multiLangShop))){ $where = " AND carrier_lang.shop_id = " . $this->shop_id; }*/ } /** Get shop informations **/ if (JeproshopShopModelShop::isTableAssociated('carrier')) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_carrier_shop') . " AS carrier_shop ON (carrier."; $query .= "carrier_id = carrier_shop.carrier_id AND carrier_shop.shop_id = " . (int) $this->shop_id . ")"; } $query .= " WHERE carrier.carrier_id = " . (int) $carrier_id . $where; $db->setQuery($query); $carrier_data = $db->loadObject(); if ($carrier_data) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_carrier_lang'); $query .= " WHERE carrier_id = " . (int) $carrier_id; $db->setQuery($query); $carrier_lang_data = $db->loadObjectList(); if ($carrier_lang_data) { foreach ($carrier_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'carrier_id') { if (!isset($carrier_data->{$key}) || !is_array($carrier_data->{$key})) { $carrier_data->{$key} = array(); } $carrier_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $carrier_data); } } else { $carrier_data = JeproshopCache::retrieve($cache_id); } if ($carrier_data) { $carrier_data->carrier_id = $carrier_id; foreach ($carrier_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } /** * keep retro-compatibility SHIPPING_METHOD_DEFAULT * @deprecated 1.5.5 */ if ($this->shipping_method == JeproshopCarrierModelCarrier::DEFAULT_SHIPPING_METHOD) { $this->shipping_method = (int) JeproshopSettingModelSetting::getValue('shipping_method') ? JeproshopCarrierModelCarrier::WEIGHT_SHIPPING_METHOD : JeproshopCarrierModelCarrier::PRICE_SHIPPING_METHOD; } /** * keep retro-compatibility id_tax_rules_group * @deprecated 1.5.0 */ if ($this->carrier_id) { $this->tax_rules_group_id = $this->getTaxRulesGroupId(JeproshopContext::getContext()); } if ($this->name == '0') { $this->name = JeproshopSettingModelSetting::getValue('shop_name'); } $this->image_dir = COM_JEPROSHOP_CARRIER_IMAGE_DIR; }
public function __construct($manufacturer_id = null, $lang_id = null) { parent::__construct(); $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($manufacturer_id) { $cache_id = 'jeproshop_manufacturer_model_' . $manufacturer_id . '_' . $lang_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_manufacturer') . " AS j_manufacturer "; $where = ""; /** get language information **/ if ($lang_id) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_manufacturer_lang') . " AS manufacturer_lang "; $query .= "ON (j_manufacturer.manufacturer_id = manufacturer_lang.manufacturer_id AND manufacturer_lang.lang_id = " . (int) $lang_id . ") "; /* if($this->shop_id && !(empty($this->multiLangShop))){ $where = " AND manufacturer_lang.shop_id = " . $this->shop_id; }*/ } /** Get shop informations ** / if(JeproshopShopModelShop::isTableAssociated('manufacturer')){ $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_manufacturer_shop') . " AS manufacturer_shop ON ("; $query .= "j_manufacturer.manufacturer_id = manufacturer_shop.manufacturer_id AND manufacturer_shop.shop_id = " . (int) $this->shop_id . ")"; }*/ $query .= " WHERE j_manufacturer.manufacturer_id = " . (int) $manufacturer_id . $where; $db->setQuery($query); $manufacturer_data = $db->loadObject(); if ($manufacturer_data) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_manufacturer_lang'); $query .= " WHERE manufacturer_id = " . (int) $manufacturer_id; $db->setQuery($query); $manufacturer_lang_data = $db->loadObjectList(); if ($manufacturer_lang_data) { foreach ($manufacturer_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'manufacturer_id') { if (!isset($manufacturer_data->{$key}) || !is_array($manufacturer_data->{$key})) { $manufacturer_data->{$key} = array(); } $manufacturer_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $manufacturer_data); } } else { $manufacturer_data = JeproshopCache::retrieve($cache_id); } if ($manufacturer_data) { $manufacturer_data->manufacturer_id = $manufacturer_id; foreach ($manufacturer_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } $this->link_rewrite = $this->getLink(); $this->image_dir = COM_JEPROSHOP_MANUFACTURER_IMAGE_DIRECTORY; }
public function __construct($feature_id = null, $lang_id = null, $shop_id = null) { if ($lang_id !== null) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== false ? $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->get_shop_from_context = false; } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($feature_id) { // Load object from database if object id is present $cache_id = 'jeproshop_feature_model_' . (int) $feature_id . '_' . (int) $this->shop_id . '_' . (int) $lang_id; if (!JeproshopCache::isStored($cache_id)) { $db = JFactory::getDBO(); $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_feature') . " AS feature "; $where = " WHERE feature." . $db->quoteName('feature_id') . " = " . (int) $feature_id; // Get lang informations if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_feature_lang') . " AS feature_lang ON (feature." . $db->quoteName('feature_id') . " = "; $query .= $db->quoteName('feature_id') . " AND feature_lang." . $db->quoteName('lang_id') . " = " . (int) $lang_id . ") "; if ($this->shop_id && !empty($this->multiLangShop)) { $where .= " AND feature_lang." . $db->quoteName('shop_id') . " = " . $this->shop_id; } } // Get shop informations if (JeproshopShopModelShop::isTableAssociated('feature')) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_feature_shop') . " AS feature_shop ON (feature." . $db->quoteName('feature_id') . " = feature_shop."; $query .= $db->quoteName('feature_id') . " AND feature_shop." . $db->quoteName('shop_id') . " = " . (int) $this->shop_id . ") "; } $db->setQuery($query . $where); $feature_data = $db->loadObject(); if ($feature_data) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_feature_lang') . " WHERE " . $db->quoteName('feature_id') . " = " . (int) $feature_id; $query .= $this->shop_id && $this->isLangMultiShop() ? " AND " . $db->quoteName('shop_id') . " = " . $this->shop_id : ""; $db->setQuery($query); $feature_data_lang = $db->loadObjectList(); if ($feature_data_lang) { foreach ($feature_data_lang as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'feature_id') { if (!isset($feature_data->{$key}) || !is_array($feature_data->{$key})) { $feature_data->{$key} = array(); } $feature_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $feature_data); } } else { $feature_data = JeproshopCache::retrieve($cache_id); } if ($feature_data) { //$this->id = (int)$id; foreach ($feature_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } }
public function __construct($order_id = null, $lang_id = null) { //parent::__construct(); $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($order_id) { $cache_id = 'jeproshop_order_model_' . $order_id . '_' . $lang_id . '_' . $this->shop_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_orders') . " AS ord "; $where = ""; /** get language information **/ if ($lang_id) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang') . " AS product_lang "; $query .= "ON (product.product_id = product_lang.product_id AND product_lang.lang_id = " . (int) $lang_id . ") "; if ($this->shop_id && !empty($this->multiLangShop)) { $where = " AND product_lang.shop_id = " . $this->shop_id; } } /** Get shop information **/ 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) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_product_lang'); $query .= " WHERE product_id = " . (int) $order_id; $db->setQuery($query); $order_lang_data = $db->loadObjectList(); if ($order_lang_data) { foreach ($order_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'order_id') { if (!isset($order_data->{$key}) || !is_array($order_data->{$key})) { $order_data->{$key} = array(); } $order_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $order_data); } } else { $order_data = JeproshopCache::retrieve($cache_id); } if ($order_data) { $order_data->product_id = $order_id; foreach ($order_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } if ($this->customer_id) { $customer = new JeproshopCustomerModelCustomer((int) $this->customer_id); $this->_taxCalculationMethod = JeproshopGroupModelGroup::getPriceDisplayMethod((int) $customer->default_group_id); } }
public function __construct($category_id = NULL, $lang_id = NULL, $shop_id = NULL) { parent::__construct(); if ($lang_id !== null) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== FALSE ? $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->getShopFromContext = FALSE; } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } $db = JFactory::getDBO(); if ($category_id) { /** load category from data base if id provided **/ $cache_id = 'jeproshop_model_category_' . (int) $category_id . '_' . $lang_id . '_' . $shop_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_category') . " AS category "; $where = ""; if ($lang_id) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_category_lang') . " AS category_lang ON ("; $query .= "category.category_id = category_lang.category_id AND category_lang.lang_id = " . (int) $lang_id . ")"; if ($this->shop_id && !empty($this->multiLangShop)) { $where .= " AND category_lang.shop_id = " . (int) $this->shop_id; } } /** Get Shop information **/ if (JeproshopShopModelShop::isTableAssociated('category')) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_category_shop') . " AS shop ON ( category."; $query .= "category_id = shop.category_id AND shop.shop_id = " . (int) $this->shop_id . ")"; } $query .= " WHERE category.category_id = " . (int) $category_id . $where; $db->setQuery($query); $category_data = $db->loadObject(); if ($category_data) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_category_lang') . " WHERE " . $db->quoteName('category_id'); $query .= $this->shop_id && $this->isLangMultiShop() ? " AND " . $db->quoteName('shop_id') . " = " . $this->shop_id : ""; $db->setQuery($query); $category_lang_data = $db->loadObjectList(); if ($category_lang_data) { foreach ($category_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'category_id') { if (!isset($category_data->{$key}) || !is_array($category_data->{$key})) { $category_data->{$key} = array(); } $category_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $category_data); } } else { $category_data = JeproshopCache::retrieve($cache_id); } if ($category_data) { $category_data->category_id = $category_id; foreach ($category_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } $this->image_id = file_exists(COM_JEPROSHOP_CATEGORY_IMAGE_DIRECTORY . (int) $this->category_id . '.jpg') ? (int) $this->category_id : FALSE; $this->image_dir = COM_JEPROSHOP_CATEGORY_IMAGE_DIRECTORY; }
public function __construct($employee_id = NULL, $lang_id = NULL, $shop_id = null) { parent::__construct(); $db = JFactory::getDBO(); if ($lang_id !== null) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) !== false ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->getShopFromContext = false; } /* if($this->isMultiShop() && !$this->shop_id){ $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if($employee_id){ /** load employee from database if employee * / $cache_id = 'jeproshop_employee_model_' . (int)$employee_id . (($lang_id) ? '_lang_' . (int)$lang_id : '') .(($shop_id) ? '_shop_' .(int)$shop_id : ''); if(!JeproshopCache::isStored($cache_id)){ $query = "SELECT * FROM " . $db->quoteName('#__users') . " AS employee LEFT JOIN " . $db->quoteName('#__jeproshop_employee'); $query .= " AS alias ON(employee.id = alias.employee_id) "; //add language filter $where = ""; if($lang_id){ $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_employee_lang') . " employee_lang ON(alias."; $query .= $db->quoteName('employee_id') . " = employee_lang." . $db->quoteName('employee_id') ; $query .= " AND employee_lang." . $db->quoteName('lang_id') . " = " . (int)$lang_id . ")"; if($this->shop_id && !empty($this->multiLangShop)){ $where = " AND employee_lang." . $db->quoteName('shop_id') . " = " . $this->shop_id; } } /** get shop information * / if(JeproshopShopModelShop::isTableAssociated('employee')){ $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_employee_shop') . " AS shop ON(alias.employee_id"; $query .= " = shop.employee_id AND shop.shop_id = " . (int)$this->shop_id . ")"; } $query .= " WHERE employee." . $db->quoteName('id') . " = " . (int)$employee_id . $where; $db->setQuery($query); $employee_data = $db->loadObject(); if($employee_data){ if(!$lang_id && isset($this->multiLang) && $this->multiLang){ $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_employee_lang') . " WHERE " . $db->quoteName('employee_id'); $query .= " = " . (int)$employee_id . (($this->shop_id && $this->isLangMultiShop()) ? " AND " . $db->quoteName('shop_id') . " = " . $this->shop_id : ""); $db->setQuery($query); $employee_lang_data = $db->loadObjectList(); if($employee_lang_data){ foreach($employee_lang_data as $row){ foreach($row as $key => $value){ if(array_key_exists($key, $this) && $key != 'employee_id'){ if(!isset($employee_data->{$key}) || !is_array($employee_data->{$key})){ $employee_data->{$key} = array(); } $employee_data->{$key}[$row->lang_id] =$value; } } } } } JeproshopCache::store($cache_id, $employee_data); } } else{ $employee_data = JeproshopCache::retrieve($cache_id); } if($employee_data){ $employee_data->employee_id = (int)$employee_id; foreach($employee_data as $key => $value){ if(array_key_exists($key, $this)){ $this->{$key} = $value; } } } } if($this->employee_id){ $this->associated_shops = $this->getAssociatedShops(); } */ $this->image_dir = COM_JEPROSHOP_EMPLOYEE_IMAGE_DIRECTORY; }
public function __construct($product_id = NULL, $full = FALSE, $lang_id = NULL, $shop_id = NULL, JeproshopContext $context = NULL) { $db = JFactory::getDBO(); if ($lang_id !== NULL) { $this->lang_id = JeproshopLanguageModelLanguage::getLanguage($lang_id) ? (int) $lang_id : JeproshopSettingModelSetting::getValue('default_lang'); } if ($shop_id && $this->isMultiShop()) { $this->shop_id = (int) $shop_id; $this->getShopFromContext = FALSE; } if ($this->isMultiShop() && !$this->shop_id) { $this->shop_id = JeproshopContext::getContext()->shop->shop_id; } if ($product_id) { $cache_id = 'jeproshop_product_model_' . $product_id . '_' . $lang_id . '_' . $shop_id; if (!JeproshopCache::isStored($cache_id)) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_product') . " AS product "; $where = ""; /** get language information **/ if ($lang_id) { $query .= "LEFT JOIN " . $db->quoteName('#__jeproshop_product_lang') . " AS product_lang "; $query .= "ON (product.product_id = product_lang.product_id AND product_lang.lang_id = " . (int) $lang_id . ") "; if ($this->shop_id && !empty($this->multiLangShop)) { $where = " AND product_lang.shop_id = " . $this->shop_id; } } /** Get shop informations **/ if (JeproshopShopModelShop::isTableAssociated('product')) { $query .= " LEFT JOIN " . $db->quoteName('#__jeproshop_product_shop') . " AS product_shop ON ("; $query .= "product.product_id = product_shop.product_id AND product_shop.shop_id = " . (int) $this->shop_id . ")"; } $query .= " WHERE product.product_id = " . (int) $product_id . $where; $db->setQuery($query); $product_data = $db->loadObject(); if ($product_data) { if (!$lang_id && isset($this->multiLang) && $this->multiLang) { $query = "SELECT * FROM " . $db->quoteName('#__jeproshop_product_lang'); $query .= " WHERE product_id = " . (int) $product_id; $db->setQuery($query); $product_lang_data = $db->loadObjectList(); if ($product_lang_data) { foreach ($product_lang_data as $row) { foreach ($row as $key => $value) { if (array_key_exists($key, $this) && $key != 'product_id') { if (!isset($product_data->{$key}) || !is_array($product_data->{$key})) { $product_data->{$key} = array(); } $product_data->{$key}[$row->lang_id] = $value; } } } } } JeproshopCache::store($cache_id, $product_data); } } else { $product_data = JeproshopCache::retrieve($cache_id); } if ($product_data) { $product_data->product_id = $product_id; foreach ($product_data as $key => $value) { if (array_key_exists($key, $this)) { $this->{$key} = $value; } } } } if (!$context) { $context = JeproshopContext::getContext(); } if ($full && $this->product_id) { $this->isFullyLoaded = $full; $this->manufacturer_name = JeproshopManufacturerModelManufacturer::getNameById((int) $this->manufacturer_id); $this->supplier_name = JeproshopSupplierModelSupplier::getNameById((int) $this->supplier_id); if ($this->getProductType() == self::VIRTUAL_PRODUCT) { $this->developer_name = JeproshopDeveloperModelDeveloper::getNameById((int) $this->developer_id); } $address = NULL; if (is_object($context->cart) && $context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')} != null) { $address = $context->cart->{JeproshopSettingModelSetting::getValue('tax_address_type')}; } $this->tax_rate = $this->getTaxesRate(new JeproshopAddressModelAddress($address)); $this->is_new = $this->isNew(); $this->base_price = $this->price; $this->price = JeproshopProductModelProduct::getStaticPrice((int) $this->product_id, false, null, 6, null, false, true, 1, false, null, null, null, $this->specific_price); $this->unit_price = $this->unit_price_ratio != 0 ? $this->price / $this->unit_price_ratio : 0; if ($this->product_id) { $this->tags = JeproshopTagModelTag::getProductTags((int) $this->product_id); } $this->loadStockData(); } if ($this->default_category_id) { $this->category = JeproshopCategoryModelCategory::getLinkRewrite((int) $this->default_category_id, (int) $lang_id); } }