示例#1
0
 public function renderDetails($tpl = null)
 {
     $tagModel = new JeproshopTagModelTag();
     $tags = $tagModel->getTagsList();
     $this->assignRef('tags', $tags);
     $this->addToolBar();
     $this->sideBar = JHtmlSideBar::render();
     parent::display($tpl);
 }
示例#2
0
 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);
     }
 }
示例#3
0
 private function initInformationsForm()
 {
     if (!$this->context->controller->default_form_language) {
         $this->languages = $this->context->controller->getLanguages();
     }
     $app = JFactory::getApplication();
     $product_name_redirected = JeproshopProductModelProduct::getProductName((int) $this->product->product_redirected_id, null, (int) $this->context->language->lang_id);
     $this->assignRef('product_name_redirected', $product_name_redirected);
     /*
      * Form for adding a virtual product like software, mp3, etc...
      */
     $product_download = new JeproshopProductDownloadModelProductDownload();
     $product_download_id = $product_download->getIdFromProductId($this->product->product_id);
     if ($product_download_id) {
         $product_download = new JeproshopProductDownloadModelProductDownload($product_download_id);
     }
     $this->product->productDownload = $product_download;
     $cache_default_attribute = (int) $this->product->cache_default_attribute;
     $product_props = array();
     // global informations
     array_push($product_props, 'reference', 'ean13', 'upc', 'available_for_order', 'show_price', 'online_only', 'manufacturer_id');
     // specific / detailed information
     array_push($product_props, 'width', 'height', 'weight', 'published', 'is_virtual', 'cache_default_attribute', 'uploadable_files', 'text_fields');
     // prices
     array_push($product_props, 'price', 'wholesale_price', 'tax_rules_group_id', 'unit_price_ratio', 'on_sale', 'unity', 'minimal_quantity', 'additional_shipping_cost', 'available_now', 'available_later', 'available_date');
     if (JeproshopSettingModelSetting::getValue('use_eco_tax')) {
         array_push($product_props, 'ecotax');
     }
     $this->product->name['class'] = 'updateCurrentText';
     if (!$this->product->product_id || JeproshopSettingModelSetting::getValue('force_friendly_product')) {
         $this->product->name['class'] .= ' copy2friendlyUrl';
     }
     $images = JeproshopImageModelImage::getImages($this->context->language->lang_id, $this->product->product_id);
     if (is_array($images)) {
         foreach ($images as $k => $image) {
             //$images[$k]->src = $this->context->controller->getImageLink($this->product->link_rewrite[$this->context->language->lang_id], $this->product->product_id.'-'.$image->image_id, 'small_default'); echo $images[$k]->src;
         }
         $this->assignRef('product_images', $images);
     }
     $imagesTypes = JeproshopImageTypeModelImageType::getImagesTypes('products');
     $this->assignRef('imagesTypes', $imagesTypes);
     $this->product->tags = JeproshopTagModelTag::getProductTags($this->product->product_id);
     $product_type = (int) $app->input->get('product_type', $this->product->getType());
     $this->assignRef('product_type', $product_type);
     $is_in_pack = (int) JeproshopProductPack::isPacked($this->product->product_id);
     $this->assignRef('is_in_pack', $is_in_pack);
     $check_product_association_ajax = false;
     if (JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() != JeproshopShopModelShop::CONTEXT_ALL) {
         $check_product_association_ajax = true;
     }
     $iso_tiny_mce = $this->context->language->iso_code;
     $iso_tiny_mce = file_exists(JURI::base() . '/components/com_jeproshop/assets/javascript/tiny_mce/langs/' . $iso_tiny_mce . '.js') ? $iso_tiny_mce : 'en';
     $this->assignRef('iso_tiny_mce', $iso_tiny_mce);
     $this->assignRef('check_product_association_ajax', $check_product_association_ajax);
     $combinationImageJs = $this->getCombinationImagesJs();
     $this->assignRef('combinationImagesJs', $combinationImageJs);
 }
示例#4
0
 /**
  * Update product tags
  *
  * @param array Languages
  * @return boolean Update result
  */
 public function updateTags($languages)
 {
     $tag_success = true;
     /* Reset all tags for THIS product */
     if (!JeproshopTagModelTag::deleteTagsForProduct((int) $this->product_id)) {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, 'An error occurred while attempting to delete previous tags.');
     }
     $input = JRequest::get('post');
     $input_data = $input['information'];
     /* Assign tags to this product */
     foreach ($languages as $language) {
         if ($value = $input_data['tag_' . $language->lang_id]) {
             $tag_success &= JeproshopTagModelTag::addTags($language->lang_id, (int) $this->product_id, $value);
         }
     }
     if (!$tag_success) {
         $this->context->controller->has_errors = true;
         JError::raiseError(500, 'An error occurred while adding tags.');
     }
     return $tag_success;
 }