示例#1
0
 public static function getValueForProduct($id_product, $id_group)
 {
     $tags = Tag::getProductTags((int) $id_product);
     $tags = $tags[1];
     if (is_array($tags) && in_array('buy1get1', $tags)) {
         return 0;
     }
     if (!isset(self::$reductionCache[$id_product . '-' . $id_group])) {
         self::$reductionCache[$id_product . '-' . $id_group] = Db::getInstance()->getValue('SELECT `reduction` FROM `' . _DB_PREFIX_ . 'product_group_reduction_cache` WHERE `id_product` = ' . (int) $id_product . ' AND `id_group` = ' . (int) $id_group);
     }
     return self::$reductionCache[$id_product . '-' . $id_group];
 }
示例#2
0
 public function __construct($id_product = NULL, $full = false, $id_lang = NULL)
 {
     global $cart;
     parent::__construct($id_product, $id_lang);
     if ($full and $this->id) {
         $this->tax_name = 'deprecated';
         // The applicable tax may be BOTH the product one AND the state one (moreover this variable is some deadcode)
         $this->manufacturer_name = Manufacturer::getNameById((int) $this->id_manufacturer);
         $this->supplier_name = Supplier::getNameById((int) $this->id_supplier);
         self::$_tax_rules_group[$this->id] = $this->id_tax_rules_group;
         if (is_object($cart) and $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')} != NULL) {
             $this->tax_rate = Tax::getProductTaxRate($this->id, $cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')});
         } else {
             $this->tax_rate = Tax::getProductTaxRate($this->id, NULL);
         }
         $this->new = $this->isNew();
         $this->price = Product::getPriceStatic((int) $this->id, false, NULL, 6, NULL, false, true, 1, false, NULL, NULL, NULL, $this->specificPrice);
         $this->unit_price = $this->unit_price_ratio != 0 ? $this->price / $this->unit_price_ratio : 0;
         if ($this->id) {
             $this->tags = Tag::getProductTags((int) $this->id);
         }
     }
     if ($this->id_category_default) {
         $this->category = Category::getLinkRewrite((int) $this->id_category_default, (int) $id_lang);
     }
 }
示例#3
0
    protected function productImportOne($info, $default_language_id, $id_lang, $force_ids, $regenerate, $shop_is_feature_active, $shop_ids, $match_ref, &$accessories, $validateOnly = false)
    {
        if ($force_ids && isset($info['id']) && (int) $info['id']) {
            $product = new Product((int) $info['id']);
        } elseif ($match_ref && array_key_exists('reference', $info)) {
            $datas = Db::getInstance()->getRow('
					SELECT p.`id_product`
					FROM `' . _DB_PREFIX_ . 'product` p
					' . Shop::addSqlAssociation('product', 'p') . '
					WHERE p.`reference` = "' . pSQL($info['reference']) . '"
				', false);
            if (isset($datas['id_product']) && $datas['id_product']) {
                $product = new Product((int) $datas['id_product']);
            } else {
                $product = new Product();
            }
        } elseif (array_key_exists('id', $info) && (int) $info['id'] && Product::existsInDatabase((int) $info['id'], 'product')) {
            $product = new Product((int) $info['id']);
        } else {
            $product = new Product();
        }
        $update_advanced_stock_management_value = false;
        if (isset($product->id) && $product->id && Product::existsInDatabase((int) $product->id, 'product')) {
            $product->loadStockData();
            $update_advanced_stock_management_value = true;
            $category_data = Product::getProductCategories((int) $product->id);
            if (is_array($category_data)) {
                foreach ($category_data as $tmp) {
                    if (!isset($product->category) || !$product->category || is_array($product->category)) {
                        $product->category[] = $tmp;
                    }
                }
            }
        }
        AdminImportController::setEntityDefaultValues($product);
        AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product);
        if (!$shop_is_feature_active) {
            $product->shop = (int) Configuration::get('PS_SHOP_DEFAULT');
        } elseif (!isset($product->shop) || empty($product->shop)) {
            $product->shop = implode($this->multiple_value_separator, Shop::getContextListShopID());
        }
        if (!$shop_is_feature_active) {
            $product->id_shop_default = (int) Configuration::get('PS_SHOP_DEFAULT');
        } else {
            $product->id_shop_default = (int) Context::getContext()->shop->id;
        }
        // link product to shops
        $product->id_shop_list = array();
        foreach (explode($this->multiple_value_separator, $product->shop) as $shop) {
            if (!empty($shop) && !is_numeric($shop)) {
                $product->id_shop_list[] = Shop::getIdByName($shop);
            } elseif (!empty($shop)) {
                $product->id_shop_list[] = $shop;
            }
        }
        if ((int) $product->id_tax_rules_group != 0) {
            if (Validate::isLoadedObject(new TaxRulesGroup($product->id_tax_rules_group))) {
                $address = $this->context->shop->getAddress();
                $tax_manager = TaxManagerFactory::getManager($address, $product->id_tax_rules_group);
                $product_tax_calculator = $tax_manager->getTaxCalculator();
                $product->tax_rate = $product_tax_calculator->getTotalRate();
            } else {
                $this->addProductWarning('id_tax_rules_group', $product->id_tax_rules_group, $this->trans('Unknown tax rule group ID. You need to create a group with this ID first.', array(), 'Admin.Parameters.Notification'));
            }
        }
        if (isset($product->manufacturer) && is_numeric($product->manufacturer) && Manufacturer::manufacturerExists((int) $product->manufacturer)) {
            $product->id_manufacturer = (int) $product->manufacturer;
        } elseif (isset($product->manufacturer) && is_string($product->manufacturer) && !empty($product->manufacturer)) {
            if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) {
                $product->id_manufacturer = (int) $manufacturer;
            } else {
                $manufacturer = new Manufacturer();
                $manufacturer->name = $product->manufacturer;
                $manufacturer->active = true;
                if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $manufacturer->add()) {
                    $product->id_manufacturer = (int) $manufacturer->id;
                    $manufacturer->associateTo($product->id_shop_list);
                } else {
                    if (!$validateOnly) {
                        $this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $manufacturer->name, isset($manufacturer->id) && !empty($manufacturer->id) ? $manufacturer->id : 'null');
                    }
                    if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
                        $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                    }
                }
            }
        }
        if (isset($product->supplier) && is_numeric($product->supplier) && Supplier::supplierExists((int) $product->supplier)) {
            $product->id_supplier = (int) $product->supplier;
        } elseif (isset($product->supplier) && is_string($product->supplier) && !empty($product->supplier)) {
            if ($supplier = Supplier::getIdByName($product->supplier)) {
                $product->id_supplier = (int) $supplier;
            } else {
                $supplier = new Supplier();
                $supplier->name = $product->supplier;
                $supplier->active = true;
                if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $supplier->add()) {
                    $product->id_supplier = (int) $supplier->id;
                    $supplier->associateTo($product->id_shop_list);
                } else {
                    if (!$validateOnly) {
                        $this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $supplier->name, isset($supplier->id) && !empty($supplier->id) ? $supplier->id : 'null');
                    }
                    if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
                        $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                    }
                }
            }
        }
        if (isset($product->price_tex) && !isset($product->price_tin)) {
            $product->price = $product->price_tex;
        } elseif (isset($product->price_tin) && !isset($product->price_tex)) {
            $product->price = $product->price_tin;
            // If a tax is already included in price, withdraw it from price
            if ($product->tax_rate) {
                $product->price = (double) number_format($product->price / (1 + $product->tax_rate / 100), 6, '.', '');
            }
        } elseif (isset($product->price_tin) && isset($product->price_tex)) {
            $product->price = $product->price_tex;
        }
        if (!Configuration::get('PS_USE_ECOTAX')) {
            $product->ecotax = 0;
        }
        if (isset($product->category) && is_array($product->category) && count($product->category)) {
            $product->id_category = array();
            // Reset default values array
            foreach ($product->category as $value) {
                if (is_numeric($value)) {
                    if (Category::categoryExists((int) $value)) {
                        $product->id_category[] = (int) $value;
                    } else {
                        $category_to_create = new Category();
                        $category_to_create->id = (int) $value;
                        $category_to_create->name = AdminImportController::createMultiLangField($value);
                        $category_to_create->active = 1;
                        $category_to_create->id_parent = Configuration::get('PS_HOME_CATEGORY');
                        // Default parent is home for unknown category to create
                        $category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]);
                        $category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite);
                        if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && !$validateOnly && $category_to_create->add()) {
                            $product->id_category[] = (int) $category_to_create->id;
                        } else {
                            if (!$validateOnly) {
                                $this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), $category_to_create->name[$default_language_id], isset($category_to_create->id) && !empty($category_to_create->id) ? $category_to_create->id : 'null');
                            }
                            if ($field_error !== true || isset($lang_field_error) && $lang_field_error !== true) {
                                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                            }
                        }
                    }
                } elseif (!$validateOnly && is_string($value) && !empty($value)) {
                    $category = Category::searchByPath($default_language_id, trim($value), $this, 'productImportCreateCat');
                    if ($category['id_category']) {
                        $product->id_category[] = (int) $category['id_category'];
                    } else {
                        $this->errors[] = sprintf($this->trans('%1$s cannot be saved', array(), 'Admin.Parameters.Notification'), trim($value));
                    }
                }
            }
            $product->id_category = array_values(array_unique($product->id_category));
            // Will update default category if category column is not ignored AND if there is categories that are set in the import file row.
            if (isset($product->id_category[0])) {
                $product->id_category_default = (int) $product->id_category[0];
            } else {
                $defaultProductShop = new Shop($product->id_shop_default);
                $product->id_category_default = Category::getRootCategory(null, Validate::isLoadedObject($defaultProductShop) ? $defaultProductShop : null)->id;
            }
        }
        // Will update default category if there is none set here. Home if no category at all.
        if (!isset($product->id_category_default) || !$product->id_category_default) {
            // this if will avoid ereasing default category if category column is not present in the CSV file (or ignored)
            if (isset($product->id_category[0])) {
                $product->id_category_default = (int) $product->id_category[0];
            } else {
                $defaultProductShop = new Shop($product->id_shop_default);
                $product->id_category_default = Category::getRootCategory(null, Validate::isLoadedObject($defaultProductShop) ? $defaultProductShop : null)->id;
            }
        }
        $link_rewrite = is_array($product->link_rewrite) && isset($product->link_rewrite[$id_lang]) ? trim($product->link_rewrite[$id_lang]) : '';
        $valid_link = Validate::isLinkRewrite($link_rewrite);
        if (isset($product->link_rewrite[$id_lang]) && empty($product->link_rewrite[$id_lang]) || !$valid_link) {
            $link_rewrite = Tools::link_rewrite($product->name[$id_lang]);
            if ($link_rewrite == '') {
                $link_rewrite = 'friendly-url-autogeneration-failed';
            }
        }
        if (!$valid_link) {
            $this->informations[] = sprintf($this->trans('Rewrite link for %1$s (ID %2$s): re-written as %3$s.', array(), 'Admin.Parameters.Notification'), $product->name[$id_lang], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null', $link_rewrite);
        }
        if (!$valid_link || !($match_ref || $force_ids) || !(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) {
            $product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite);
        }
        // replace the value of separator by coma
        if ($this->multiple_value_separator != ',') {
            if (is_array($product->meta_keywords)) {
                foreach ($product->meta_keywords as &$meta_keyword) {
                    if (!empty($meta_keyword)) {
                        $meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword);
                    }
                }
            }
        }
        // Convert comma into dot for all floating values
        foreach (Product::$definition['fields'] as $key => $array) {
            if ($array['type'] == Product::TYPE_FLOAT) {
                $product->{$key} = str_replace(',', '.', $product->{$key});
            }
        }
        // Indexation is already 0 if it's a new product, but not if it's an update
        $product->indexed = 0;
        $productExistsInDatabase = false;
        if ($product->id && Product::existsInDatabase((int) $product->id, 'product')) {
            $productExistsInDatabase = true;
        }
        if ($match_ref && $product->reference && $product->existsRefInDatabase($product->reference) || $productExistsInDatabase) {
            $product->date_upd = date('Y-m-d H:i:s');
        }
        $res = false;
        $field_error = $product->validateFields(UNFRIENDLY_ERROR, true);
        $lang_field_error = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
        if ($field_error === true && $lang_field_error === true) {
            // check quantity
            if ($product->quantity == null) {
                $product->quantity = 0;
            }
            // If match ref is specified && ref product && ref product already in base, trying to update
            if ($match_ref && $product->reference && $product->existsRefInDatabase($product->reference)) {
                $datas = Db::getInstance()->getRow('
					SELECT product_shop.`date_add`, p.`id_product`
					FROM `' . _DB_PREFIX_ . 'product` p
					' . Shop::addSqlAssociation('product', 'p') . '
					WHERE p.`reference` = "' . pSQL($product->reference) . '"
				', false);
                $product->id = (int) $datas['id_product'];
                $product->date_add = pSQL($datas['date_add']);
                $res = $validateOnly || $product->update();
            } elseif ($productExistsInDatabase) {
                $datas = Db::getInstance()->getRow('
					SELECT product_shop.`date_add`
					FROM `' . _DB_PREFIX_ . 'product` p
					' . Shop::addSqlAssociation('product', 'p') . '
					WHERE p.`id_product` = ' . (int) $product->id, false);
                $product->date_add = pSQL($datas['date_add']);
                $res = $validateOnly || $product->update();
            }
            // If no id_product or update failed
            $product->force_id = (bool) $force_ids;
            if (!$res) {
                if (isset($product->date_add) && $product->date_add != '') {
                    $res = $validateOnly || $product->add(false);
                } else {
                    $res = $validateOnly || $product->add();
                }
            }
            if (!$validateOnly) {
                if ($product->getType() == Product::PTYPE_VIRTUAL) {
                    StockAvailable::setProductOutOfStock((int) $product->id, 1);
                } else {
                    StockAvailable::setProductOutOfStock((int) $product->id, (int) $product->out_of_stock);
                }
                if ($product_download_id = ProductDownload::getIdFromIdProduct((int) $product->id)) {
                    $product_download = new ProductDownload($product_download_id);
                    $product_download->delete(true);
                }
                if ($product->getType() == Product::PTYPE_VIRTUAL) {
                    $product_download = new ProductDownload();
                    $product_download->filename = ProductDownload::getNewFilename();
                    Tools::copy($info['file_url'], _PS_DOWNLOAD_DIR_ . $product_download->filename);
                    $product_download->id_product = (int) $product->id;
                    $product_download->nb_downloadable = (int) $info['nb_downloadable'];
                    $product_download->date_expiration = $info['date_expiration'];
                    $product_download->nb_days_accessible = (int) $info['nb_days_accessible'];
                    $product_download->display_filename = basename($info['file_url']);
                    $product_download->add();
                }
            }
        }
        $shops = array();
        $product_shop = explode($this->multiple_value_separator, $product->shop);
        foreach ($product_shop as $shop) {
            if (empty($shop)) {
                continue;
            }
            $shop = trim($shop);
            if (!empty($shop) && !is_numeric($shop)) {
                $shop = Shop::getIdByName($shop);
            }
            if (in_array($shop, $shop_ids)) {
                $shops[] = $shop;
            } else {
                $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Shop is not valid'));
            }
        }
        if (empty($shops)) {
            $shops = Shop::getContextListShopID();
        }
        // If both failed, mysql error
        if (!$res) {
            $this->errors[] = sprintf($this->trans('%1$s (ID: %2$s) cannot be saved', array(), 'Admin.Parameters.Notification'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
            $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
        } else {
            // Product supplier
            if (!$validateOnly && isset($product->id) && $product->id && isset($product->id_supplier) && property_exists($product, 'supplier_reference')) {
                $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier);
                if ($id_product_supplier) {
                    $product_supplier = new ProductSupplier($id_product_supplier);
                } else {
                    $product_supplier = new ProductSupplier();
                }
                $product_supplier->id_product = (int) $product->id;
                $product_supplier->id_product_attribute = 0;
                $product_supplier->id_supplier = (int) $product->id_supplier;
                $product_supplier->product_supplier_price_te = $product->wholesale_price;
                $product_supplier->product_supplier_reference = $product->supplier_reference;
                $product_supplier->save();
            }
            // SpecificPrice (only the basic reduction feature is supported by the import)
            if (!$shop_is_feature_active) {
                $info['shop'] = 1;
            } elseif (!isset($info['shop']) || empty($info['shop'])) {
                $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
            }
            // Get shops for each attributes
            $info['shop'] = explode($this->multiple_value_separator, $info['shop']);
            $id_shop_list = array();
            foreach ($info['shop'] as $shop) {
                if (!empty($shop) && !is_numeric($shop)) {
                    $id_shop_list[] = (int) Shop::getIdByName($shop);
                } elseif (!empty($shop)) {
                    $id_shop_list[] = $shop;
                }
            }
            if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) {
                foreach ($id_shop_list as $id_shop) {
                    $specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
                    if (is_array($specific_price) && isset($specific_price['id_specific_price'])) {
                        $specific_price = new SpecificPrice((int) $specific_price['id_specific_price']);
                    } else {
                        $specific_price = new SpecificPrice();
                    }
                    $specific_price->id_product = (int) $product->id;
                    $specific_price->id_specific_price_rule = 0;
                    $specific_price->id_shop = $id_shop;
                    $specific_price->id_currency = 0;
                    $specific_price->id_country = 0;
                    $specific_price->id_group = 0;
                    $specific_price->price = -1;
                    $specific_price->id_customer = 0;
                    $specific_price->from_quantity = 1;
                    $specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
                    $specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
                    $specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
                    $specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
                    if (!$validateOnly && !$specific_price->save()) {
                        $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
                    }
                }
            }
            if (!$validateOnly && isset($product->tags) && !empty($product->tags)) {
                if (isset($product->id) && $product->id) {
                    $tags = Tag::getProductTags($product->id);
                    if (is_array($tags) && count($tags)) {
                        if (!empty($product->tags)) {
                            $product->tags = explode($this->multiple_value_separator, $product->tags);
                        }
                        if (is_array($product->tags) && count($product->tags)) {
                            foreach ($product->tags as $key => $tag) {
                                if (!empty($tag)) {
                                    $product->tags[$key] = trim($tag);
                                }
                            }
                            $tags[$id_lang] = $product->tags;
                            $product->tags = $tags;
                        }
                    }
                }
                // Delete tags for this id product, for no duplicating error
                Tag::deleteTagsForProduct($product->id);
                if (!is_array($product->tags) && !empty($product->tags)) {
                    $product->tags = AdminImportController::createMultiLangField($product->tags);
                    foreach ($product->tags as $key => $tags) {
                        $is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
                        if (!$is_tag_added) {
                            $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid'));
                            break;
                        }
                    }
                } else {
                    foreach ($product->tags as $key => $tags) {
                        $str = '';
                        foreach ($tags as $one_tag) {
                            $str .= $one_tag . $this->multiple_value_separator;
                        }
                        $str = rtrim($str, $this->multiple_value_separator);
                        $is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
                        if (!$is_tag_added) {
                            $this->addProductWarning(Tools::safeOutput($info['name']), (int) $product->id, 'Invalid tag(s) (' . $str . ')');
                            break;
                        }
                    }
                }
            }
            //delete existing images if "delete_existing_images" is set to 1
            if (!$validateOnly && isset($product->delete_existing_images)) {
                if ((bool) $product->delete_existing_images) {
                    $product->deleteImages();
                }
            }
            if (!$validateOnly && isset($product->image) && is_array($product->image) && count($product->image)) {
                $product_has_images = (bool) Image::getImages($this->context->language->id, (int) $product->id);
                foreach ($product->image as $key => $url) {
                    $url = trim($url);
                    $error = false;
                    if (!empty($url)) {
                        $url = str_replace(' ', '%20', $url);
                        $image = new Image();
                        $image->id_product = (int) $product->id;
                        $image->position = Image::getHighestPosition($product->id) + 1;
                        $image->cover = !$key && !$product_has_images ? true : false;
                        $alt = $product->image_alt[$key];
                        if (strlen($alt) > 0) {
                            $image->legend = self::createMultiLangField($alt);
                        }
                        // file_exists doesn't work with HTTP protocol
                        if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add()) {
                            // associate image to selected shops
                            $image->associateTo($shops);
                            if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !$regenerate)) {
                                $image->delete();
                                $this->warnings[] = sprintf($this->trans('Error copying image: %s', array(), 'Admin.Parameters.Notification'), $url);
                            }
                        } else {
                            $error = true;
                        }
                    } else {
                        $error = true;
                    }
                    if ($error) {
                        $this->warnings[] = sprintf($this->trans('Product #%1$d: the picture (%2$s) cannot be saved.', array(), 'Admin.Parameters.Notification'), $image->id_product, $url);
                    }
                }
            }
            if (!$validateOnly && isset($product->id_category) && is_array($product->id_category)) {
                $product->updateCategories(array_map('intval', $product->id_category));
            }
            $product->checkDefaultAttributes();
            if (!$validateOnly && !$product->cache_default_attribute) {
                Product::updateDefaultAttribute($product->id);
            }
            // Features import
            $features = get_object_vars($product);
            if (!$validateOnly && isset($features['features']) && !empty($features['features'])) {
                foreach (explode($this->multiple_value_separator, $features['features']) as $single_feature) {
                    if (empty($single_feature)) {
                        continue;
                    }
                    $tab_feature = explode(':', $single_feature);
                    $feature_name = isset($tab_feature[0]) ? trim($tab_feature[0]) : '';
                    $feature_value = isset($tab_feature[1]) ? trim($tab_feature[1]) : '';
                    $position = isset($tab_feature[2]) ? (int) $tab_feature[2] - 1 : false;
                    $custom = isset($tab_feature[3]) ? (int) $tab_feature[3] : false;
                    if (!empty($feature_name) && !empty($feature_value)) {
                        $id_feature = (int) Feature::addFeatureImport($feature_name, $position);
                        $id_product = null;
                        if ($force_ids || $match_ref) {
                            $id_product = (int) $product->id;
                        }
                        $id_feature_value = (int) FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom);
                        Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
                    }
                }
            }
            // clean feature positions to avoid conflict
            Feature::cleanPositions();
            // set advanced stock managment
            if (!$validateOnly && isset($product->advanced_stock_management)) {
                if ($product->advanced_stock_management != 1 && $product->advanced_stock_management != 0) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management has incorrect value. Not set for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
                } elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management == 1) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot enable on product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
                } elseif ($update_advanced_stock_management_value) {
                    $product->setAdvancedStockManagement($product->advanced_stock_management);
                }
                // automaticly disable depends on stock, if a_s_m set to disabled
                if (StockAvailable::dependsOnStock($product->id) == 1 && $product->advanced_stock_management == 0) {
                    StockAvailable::setProductDependsOnStock($product->id, 0);
                }
            }
            // Check if warehouse exists
            if (isset($product->warehouse) && $product->warehouse) {
                if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, warehouse not set on product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
                } elseif (!$validateOnly) {
                    if (Warehouse::exists($product->warehouse)) {
                        // Get already associated warehouses
                        $associated_warehouses_collection = WarehouseProductLocation::getCollection($product->id);
                        // Delete any entry in warehouse for this product
                        foreach ($associated_warehouses_collection as $awc) {
                            $awc->delete();
                        }
                        $warehouse_location_entity = new WarehouseProductLocation();
                        $warehouse_location_entity->id_product = $product->id;
                        $warehouse_location_entity->id_product_attribute = 0;
                        $warehouse_location_entity->id_warehouse = $product->warehouse;
                        if (WarehouseProductLocation::getProductLocation($product->id, 0, $product->warehouse) !== false) {
                            $warehouse_location_entity->update();
                        } else {
                            $warehouse_location_entity->save();
                        }
                        StockAvailable::synchronize($product->id);
                    } else {
                        $this->warnings[] = sprintf($this->trans('Warehouse did not exist, cannot set on product %1$s.', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
                    }
                }
            }
            // stock available
            if (isset($product->depends_on_stock)) {
                if ($product->depends_on_stock != 0 && $product->depends_on_stock != 1) {
                    $this->warnings[] = sprintf($this->trans('Incorrect value for "Depends on stock" for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
                } elseif ((!$product->advanced_stock_management || $product->advanced_stock_management == 0) && $product->depends_on_stock == 1) {
                    $this->warnings[] = sprintf($this->trans('Advanced stock management is not enabled, cannot set "Depends on stock" for product %1$s ', array(), 'Admin.Parameters.Notification'), $product->name[$default_language_id]);
                } elseif (!$validateOnly) {
                    StockAvailable::setProductDependsOnStock($product->id, $product->depends_on_stock);
                }
                // This code allows us to set qty and disable depends on stock
                if (!$validateOnly && isset($product->quantity) && (int) $product->quantity) {
                    // if depends on stock and quantity, add quantity to stock
                    if ($product->depends_on_stock == 1) {
                        $stock_manager = StockManagerFactory::getManager();
                        $price = str_replace(',', '.', $product->wholesale_price);
                        if ($price == 0) {
                            $price = 1.0E-6;
                        }
                        $price = round(floatval($price), 6);
                        $warehouse = new Warehouse($product->warehouse);
                        if ($stock_manager->addProduct((int) $product->id, 0, $warehouse, (int) $product->quantity, 1, $price, true)) {
                            StockAvailable::synchronize((int) $product->id);
                        }
                    } else {
                        if ($shop_is_feature_active) {
                            foreach ($shops as $shop) {
                                StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $shop);
                            }
                        } else {
                            StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $this->context->shop->id);
                        }
                    }
                }
            } elseif (!$validateOnly) {
                // if not depends_on_stock set, use normal qty
                if ($shop_is_feature_active) {
                    foreach ($shops as $shop) {
                        StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $shop);
                    }
                } else {
                    StockAvailable::setQuantity((int) $product->id, 0, (int) $product->quantity, (int) $this->context->shop->id);
                }
            }
            // Accessories linkage
            if (isset($product->accessories) && !$validateOnly && is_array($product->accessories) && count($product->accessories)) {
                $accessories[$product->id] = $product->accessories;
            }
        }
    }
示例#4
0
 /**
  * Price calculation / Get product price
  *
  * @param integer $id_shop Shop id
  * @param integer $id_product Product id
  * @param integer $id_product_attribute Product attribute id
  * @param integer $id_country Country id
  * @param integer $id_state State id
  * @param integer $id_currency Currency id
  * @param integer $id_group Group id
  * @param integer $quantity Quantity Required for Specific prices : quantity discount application
  * @param boolean $use_tax with (1) or without (0) tax
  * @param integer $decimals Number of decimals returned
  * @param boolean $only_reduc Returns only the reduction amount
  * @param boolean $use_reduc Set if the returned amount will include reduction
  * @param boolean $with_ecotax insert ecotax in price output.
  * @param variable_reference $specific_price_output If a specific price applies regarding the previous parameters, this variable is filled with the corresponding SpecificPrice object
  * @return float Product price
  **/
 public static function priceCalculation($id_shop, $id_product, $id_product_attribute, $id_country, $id_state, $id_county, $id_currency, $id_group, $quantity, $use_tax, $decimals, $only_reduc, $use_reduc, $with_ecotax, &$specific_price, $id_affiliate)
 {
     //Checking product tags
     $tags = Tag::getProductTags((int) $id_product);
     $tags = $tags[1];
     if (is_array($tags) && in_array('buy1get1', $tags) && empty($id_affiliate)) {
         $b1g1 = true;
         $use_reduc = false;
     }
     // Caching
     if ($id_product_attribute === NULL) {
         $product_attribute_label = 'NULL';
     } else {
         $product_attribute_label = $id_product_attribute === false ? 'false' : $id_product_attribute;
     }
     $cacheId = $id_product . '-' . $id_shop . '-' . $id_currency . '-' . $id_country . '-' . $id_state . '-' . $id_county . '-' . $id_group . '-' . $quantity . '-' . $product_attribute_label . '-' . ($use_tax ? '1' : '0') . '-' . $decimals . '-' . ($only_reduc ? '1' : '0') . '-' . ($use_reduc ? '1' : '0') . '-' . $with_ecotax . '-' . (int) $id_affiliate;
     // Cache for specific prices
     $cacheId3 = $id_product . '-' . $id_shop . '-' . $id_currency . '-' . $id_country . '-' . $id_group . '-' . $quantity;
     // reference parameter is filled before any returns
     $specific_price = SpecificPrice::getSpecificPrice((int) $id_product, $id_shop, $id_currency, $id_country, $id_group, $quantity, $id_affiliate);
     if (isset(self::$_prices[$cacheId])) {
         return self::$_prices[$cacheId];
     }
     // fetch price & attribute price
     $cacheId2 = $id_product . '-' . $id_product_attribute;
     if (!isset(self::$_pricesLevel2[$cacheId2])) {
         self::$_pricesLevel2[$cacheId2] = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow('
         SELECT p.`price`,
         ' . ($id_product_attribute ? 'pa.`price`' : 'IFNULL((SELECT pa.price FROM `' . _DB_PREFIX_ . 'product_attribute` pa WHERE id_product = ' . (int) $id_product . ' AND default_on = 1), 0)') . ' AS attribute_price,
         p.`ecotax`
         ' . ($id_product_attribute ? ', pa.`ecotax` AS attribute_ecotax' : '') . '
         FROM `' . _DB_PREFIX_ . 'product` p
         ' . ($id_product_attribute ? 'LEFT JOIN `' . _DB_PREFIX_ . 'product_attribute` pa ON pa.`id_product_attribute` = ' . (int) $id_product_attribute : '') . '
         WHERE p.`id_product` = ' . (int) $id_product);
     }
     $result = self::$_pricesLevel2[$cacheId2];
     $price = (double) (!$specific_price or $specific_price['price'] == 0) ? $result['price'] : $specific_price['price'];
     // convert only if the specific price is in the default currency (id_currency = 0)
     if (!$specific_price or !($specific_price['price'] > 0 and $specific_price['id_currency'])) {
         $price = Tools::convertPrice($price, $id_currency);
     }
     // Attribute price
     $attribute_price = Tools::convertPrice(array_key_exists('attribute_price', $result) ? (double) $result['attribute_price'] : 0, $id_currency);
     if ($id_product_attribute !== false) {
         // If you want the default combination, please use NULL value instead
         $price += $attribute_price;
     }
     // TaxRate calculation
     $tax_rate = Tax::getProductTaxRateViaRules((int) $id_product, (int) $id_country, (int) $id_state, (int) $id_county);
     if ($tax_rate === false) {
         $tax_rate = 0;
     }
     // Add Tax
     if ($use_tax) {
         $price = $price * (1 + $tax_rate / 100);
     }
     $price = Tools::ps_round($price, $decimals);
     // Reduction
     $reduc = 0;
     if (($only_reduc or $use_reduc) and $specific_price) {
         if ($specific_price['reduction_type'] == 'amount') {
             $reduction_amount = $specific_price['reduction'];
             if (!$specific_price['id_currency']) {
                 $reduction_amount = Tools::convertPrice($reduction_amount, $id_currency);
             }
             $reduc = Tools::ps_round(!$use_tax ? $reduction_amount / (1 + $tax_rate / 100) : $reduction_amount, $decimals);
         } else {
             $reduc = Tools::ps_round($price * $specific_price['reduction'], $decimals);
         }
     }
     if ($only_reduc && !empty($b1g1)) {
         return 0;
     } else {
         if ($only_reduc) {
             return $reduc;
         }
     }
     if ($use_reduc) {
         $price -= $reduc;
     }
     // Group reduction
     if ($reductionFromCategory = (double) GroupReduction::getValueForProduct($id_product, $id_group)) {
         $price -= $price * $reductionFromCategory;
     } else {
         // apply group reduction if there is no group reduction for this category
         $price *= (100 - Group::getReductionByIdGroup($id_group)) / 100;
     }
     $price = Tools::ps_round($price, $decimals);
     // Eco Tax
     if (($result['ecotax'] or isset($result['attribute_ecotax'])) and $with_ecotax) {
         $ecotax = $result['ecotax'];
         if (isset($result['attribute_ecotax']) && $result['attribute_ecotax'] > 0) {
             $ecotax = $result['ecotax'];
         }
         if ($id_currency) {
             $ecotax = Tools::convertPrice($ecotax, $id_currency);
         }
         if ($use_tax) {
             $taxRate = TaxRulesGroup::getTaxesRate((int) Configuration::get('PS_ECOTAX_TAX_RULES_GROUP_ID'), (int) $id_country, (int) $id_state, (int) $id_county);
             $price += $ecotax * (1 + $taxRate / 100);
         } else {
             $price += $ecotax;
         }
     }
     $price = Tools::ps_round($price, $decimals);
     if ($price < 0) {
         $price = 0;
     }
     self::$_prices[$cacheId] = $price;
     return self::$_prices[$cacheId];
 }
示例#5
0
 public function getTags($id_lang)
 {
     if (!$this->isFullyLoaded && is_null($this->tags)) {
         $this->tags = Tag::getProductTags($this->id);
     }
     if (!($this->tags && key_exists($id_lang, $this->tags))) {
         return '';
     }
     $result = '';
     foreach ($this->tags[$id_lang] as $tag_name) {
         $result .= $tag_name . ', ';
     }
     return rtrim($result, ', ');
 }
    function displayFormInformations($obj, $currency)
    {
        parent::displayForm(false);
        global $currentIndex, $cookie, $link;
        $default_country = new Country((int) Configuration::get('PS_COUNTRY_DEFAULT'));
        $iso = Language::getIsoById((int) $cookie->id_lang);
        $has_attribute = false;
        $qty_state = 'readonly';
        $qty = Attribute::getAttributeQty($this->getFieldValue($obj, 'id_product'));
        if ($qty === false) {
            if (Validate::isLoadedObject($obj)) {
                $qty = $this->getFieldValue($obj, 'quantity');
            } else {
                $qty = 1;
            }
            $qty_state = '';
        } else {
            $has_attribute = true;
        }
        $cover = Product::getCover($obj->id);
        $this->_applyTaxToEcotax($obj);
        echo '
		<div class="tab-page" id="step1">
			<h4 class="tab">1. ' . $this->l('Info.') . '</h4>
			<script type="text/javascript">
				$(document).ready(function() {
					updateCurrentText();
					updateFriendlyURL();
					$.ajax({
						url: "' . dirname($currentIndex) . '/ajax.php",
						cache: false,
						dataType: "json",
						data: "ajaxProductManufacturers=1",
						success: function(j) {
							var options = $("select#id_manufacturer").html();
							if (j)
							for (var i = 0; i < j.length; i++)
								options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
							$("select#id_manufacturer").html(options);
						},
						error: function(XMLHttpRequest, textStatus, errorThrown)
						{
							alert(\'Manufacturer ajax error: \'+textStatus);
						}

					});
					$.ajax({
						url: "' . dirname($currentIndex) . '/ajax.php",
						cache: false,
						dataType: "json",
						data: "ajaxProductSuppliers=1",
						success: function(j) {
							var options = $("select#id_supplier").html();
							if (j)
							for (var i = 0; i < j.length; i++)
								options += \'<option value="\' + j[i].optionValue + \'">\' + j[i].optionDisplay + \'</option>\';
							$("select#id_supplier").html(options);
						},
						error: function(XMLHttpRequest, textStatus, errorThrown)
						{
							alert(\'Supplier ajax error: \'+textStatus);
						}

					});
					if ($(\'#available_for_order\').is(\':checked\')){
						$(\'#show_price\').attr(\'checked\', \'checked\');
						$(\'#show_price\').attr(\'disabled\', \'disabled\');
					}
					else {
						$(\'#show_price\').attr(\'disabled\', \'\');
					}
				});
			</script>
			<b>' . $this->l('Product global information') . '</b>&nbsp;-&nbsp;';
        $preview_url = '';
        if (isset($obj->id)) {
            $preview_url = $link->getProductLink($this->getFieldValue($obj, 'id'), $this->getFieldValue($obj, 'link_rewrite', $this->_defaultFormLanguage), Category::getLinkRewrite($this->getFieldValue($obj, 'id_category_default'), (int) $cookie->id_lang));
            if (!$obj->active) {
                $admin_dir = dirname($_SERVER['PHP_SELF']);
                $admin_dir = substr($admin_dir, strrpos($admin_dir, '/') + 1);
                $token = Tools::encrypt('PreviewProduct' . $obj->id);
                $preview_url .= $obj->active ? '' : '&adtoken=' . $token . '&ad=' . $admin_dir;
            }
            echo '
			<a href="index.php?tab=AdminCatalog&id_product=' . $obj->id . '&deleteproduct&token=' . $this->token . '" style="float:right;"
			onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');">
			<img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" title="' . $this->l('Delete this product') . '" /> ' . $this->l('Delete this product') . '</a>
			<a href="' . $preview_url . '" target="_blank"><img src="../img/admin/details.gif" alt="' . $this->l('View product in shop') . '" title="' . $this->l('View product in shop') . '" /> ' . $this->l('View product in shop') . '</a>';
            if (file_exists(_PS_MODULE_DIR_ . 'statsproduct/statsproduct.php')) {
                echo '&nbsp;-&nbsp;<a href="index.php?tab=AdminStats&module=statsproduct&id_product=' . $obj->id . '&token=' . Tools::getAdminToken('AdminStats' . (int) Tab::getIdFromClassName('AdminStats') . (int) $cookie->id_employee) . '"><img src="../modules/statsproduct/logo.gif" alt="' . $this->l('View product sales') . '" title="' . $this->l('View product sales') . '" /> ' . $this->l('View product sales') . '</a>';
            }
        }
        echo '
			<hr class="clear"/>
			<br />
				<table cellpadding="5" style="width: 50%; float: left; margin-right: 20px; border-right: 1px solid #E0D0B1;">
					<tr>
						<td class="col-left">' . $this->l('Name:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
								<input size="43" type="text" id="name_' . $language['id_lang'] . '" name="name_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlspecialchars($this->getFieldValue($obj, 'name', $language['id_lang']))) . '"' . (!$obj->id ? ' onkeyup="if (isArrowKey(event)) return; copy2friendlyURL();"' : '') . ' onkeyup="if (isArrowKey(event)) return; updateCurrentText();" onchange="updateCurrentText();" /><sup> *</sup>
								<span class="hint" name="help_box">' . $this->l('Invalid characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        echo '		</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Reference:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" type="text" name="reference" value="' . htmlentities($this->getFieldValue($obj, 'reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
							<span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer">&nbsp;</span></span>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Supplier Reference:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" type="text" name="supplier_reference" value="' . htmlentities($this->getFieldValue($obj, 'supplier_reference'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
							<span class="hint" name="help_box">' . $this->l('Special characters allowed:') . ' .-_#\\<span class="hint-pointer">&nbsp;</span></span>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('EAN13 or JAN:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" maxlength="13" type="text" name="ean13" value="' . htmlentities($this->getFieldValue($obj, 'ean13'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 5px;" /> <span class="small">' . $this->l('(Europe, Japan)') . '</span>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('UPC:') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" maxlength="12" type="text" name="upc" value="' . htmlentities($this->getFieldValue($obj, 'upc'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 5px;" /> <span class="small">' . $this->l('(US, Canada)') . '</span>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Location (warehouse):') . '</td>
						<td style="padding-bottom:5px;">
							<input size="55" type="text" name="location" value="' . htmlentities($this->getFieldValue($obj, 'location'), ENT_COMPAT, 'UTF-8') . '" style="width: 130px; margin-right: 44px;" />
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Width ( package ) :') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="width" type="text" value="' . htmlentities($this->getFieldValue($obj, 'width'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . '
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Height ( package ) :') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="height" type="text" value="' . htmlentities($this->getFieldValue($obj, 'height'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . '
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Deep ( package ) :') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="depth" type="text" value="' . htmlentities($this->getFieldValue($obj, 'depth'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_DIMENSION_UNIT') . '
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Weight ( package ) :') . '</td>
						<td style="padding-bottom:5px;">
							<input size="6" maxlength="6" name="weight" type="text" value="' . htmlentities($this->getFieldValue($obj, 'weight'), ENT_COMPAT, 'UTF-8') . '" onKeyUp="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\');" /> ' . Configuration::get('PS_WEIGHT_UNIT') . '
						</td>
					</tr>
				</table>
				<table cellpadding="5" style="width: 40%; float: left; margin-left: 10px;">
					<tr>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Status:') . '</td>
						<td style="padding-bottom:5px;">
							<input style="float:left;" onclick="toggleDraftWarning(false);showOptions(true);" type="radio" name="active" id="active_on" value="1" ' . ($this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
							<label for="active_on" class="t"><img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" style="float:left; padding:0px 5px 0px 5px;" />' . $this->l('Enabled') . '</label>
							<br class="clear" />
							<input style="float:left;" onclick="toggleDraftWarning(true);showOptions(false);"  type="radio" name="active" id="active_off" value="0" ' . (!$this->getFieldValue($obj, 'active') ? 'checked="checked" ' : '') . '/>
							<label for="active_off" class="t"><img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('Disabled') . ($obj->active ? '' : ' (<a href="' . $preview_url . '" alt="" target="_blank">' . $this->l('View product in shop') . '</a>)') . '</label>
						</td>
					</tr>
					<tr id="product_options" ' . (!$obj->active ? 'style="display:none"' : '') . '>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Options:') . '</td>
						<td style="padding-bottom:5px;">
							<input style="float: left;" type="checkbox" name="available_for_order" id="available_for_order" value="1" ' . ($this->getFieldValue($obj, 'available_for_order') ? 'checked="checked" ' : '') . ' onclick="if ($(this).is(\':checked\')){$(\'#show_price\').attr(\'checked\', \'checked\');$(\'#show_price\').attr(\'disabled\', \'disabled\');}else{$(\'#show_price\').attr(\'disabled\', \'\');}"/>
							<label for="available_for_order" class="t"><img src="../img/admin/products.gif" alt="' . $this->l('available for order') . '" title="' . $this->l('available for order') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('available for order') . '</label>
							<br class="clear" />
							<input style="float: left;" type="checkbox" name="show_price" id="show_price" value="1" ' . ($this->getFieldValue($obj, 'show_price') ? 'checked="checked" ' : '') . ' />
							<label for="show_price" class="t"><img src="../img/admin/gold.gif" alt="' . $this->l('display price') . '" title="' . $this->l('show price') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('show price') . '</label>
							<br class="clear" />
							<input style="float: left;" type="checkbox" name="online_only" id="online_only" value="1" ' . ($this->getFieldValue($obj, 'online_only') ? 'checked="checked" ' : '') . ' />
							<label for="online_only" class="t"><img src="../img/admin/basket_error.png" alt="' . $this->l('online only') . '" title="' . $this->l('online only') . '" style="float:left; padding:0px 5px 0px 5px" />' . $this->l('online only (not sold in store)') . '</label>
						</td>
					</tr>
					<tr>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Condition:') . '</td>
						<td style="padding-bottom:5px;">
							<select name="condition" id="condition">
								<option value="new" ' . ($obj->condition == 'new' ? 'selected="selected"' : '') . '>' . $this->l('New') . '</option>
								<option value="used" ' . ($obj->condition == 'used' ? 'selected="selected"' : '') . '>' . $this->l('Used') . '</option>
								<option value="refurbished" ' . ($obj->condition == 'refurbished' ? 'selected="selected"' : '') . '>' . $this->l('Refurbished') . '</option>
							</select>
						</td>
					</tr>
					<tr>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Manufacturer:') . '</td>
						<td style="padding-bottom:5px;">
							<select name="id_manufacturer" id="id_manufacturer">
								<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
        if ($id_manufacturer = $this->getFieldValue($obj, 'id_manufacturer')) {
            echo '				<option value="' . $id_manufacturer . '" selected="selected">' . Manufacturer::getNameById($id_manufacturer) . '</option>
								<option disabled="disabled">----------</option>';
        }
        echo '
							</select>&nbsp;&nbsp;&nbsp;<a href="?tab=AdminManufacturers&addmanufacturer&token=' . Tools::getAdminToken('AdminManufacturers' . (int) Tab::getIdFromClassName('AdminManufacturers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete product information entered?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
						</td>
					</tr>
					<tr>
						<td style="vertical-align:top;text-align:right;padding-right:10px;font-weight:bold;">' . $this->l('Supplier:') . '</td>
						<td style="padding-bottom:5px;">
							<select name="id_supplier" id="id_supplier">
								<option value="0">-- ' . $this->l('Choose (optional)') . ' --</option>';
        if ($id_supplier = $this->getFieldValue($obj, 'id_supplier')) {
            echo '				<option value="' . $id_supplier . '" selected="selected">' . Supplier::getNameById($id_supplier) . '</option>
								<option disabled="disabled">----------</option>';
        }
        echo '
							</select>&nbsp;&nbsp;&nbsp;<a href="?tab=AdminSuppliers&addsupplier&token=' . Tools::getAdminToken('AdminSuppliers' . (int) Tab::getIdFromClassName('AdminSuppliers') . (int) $cookie->id_employee) . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a>
						</td>
					</tr>
				</table>
				<div class="clear"></div>
				<table cellpadding="5" style="width: 100%;">
					<tr><td colspan="2"><hr style="width:100%;" /></td></tr>';
        $this->displayPack($obj);
        echo '		<tr><td colspan="2"><hr style="width:100%;" /></td></tr>';
        /*
         * Form for add a virtual product like software, mp3, etc...
         */
        $productDownload = new ProductDownload();
        if ($id_product_download = $productDownload->getIdFromIdProduct($this->getFieldValue($obj, 'id'))) {
            $productDownload = new ProductDownload($id_product_download);
        }
        ?>
	<script type="text/javascript">
	// <![CDATA[
		ThickboxI18nImage = '<?php 
        echo $this->l('Image');
        ?>
';
		ThickboxI18nOf = '<?php 
        echo $this->l('of');
        ?>
';
		ThickboxI18nClose = '<?php 
        echo $this->l('Close');
        ?>
';
		ThickboxI18nOrEscKey = '<?php 
        echo $this->l('(or "Esc")');
        ?>
';
		ThickboxI18nNext = '<?php 
        echo $this->l('Next >');
        ?>
';
		ThickboxI18nPrev = '<?php 
        echo $this->l('< Previous');
        ?>
';
		tb_pathToImage = '../img/loadingAnimation.gif';
	//]]>
	</script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
jquery/thickbox-modified.js"></script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
jquery/ajaxfileupload.js"></script>
	<script type="text/javascript" src="<?php 
        echo _PS_JS_DIR_;
        ?>
date.js"></script>
	<style type="text/css">
		<!--
		@import url(<?php 
        echo _PS_CSS_DIR_;
        ?>
thickbox.css);
		-->
	</style>
	<script type="text/javascript">
	//<![CDATA[
	function toggleVirtualProduct(elt)
	{
		if (elt.checked)
		{
			$('#virtual_good').show('slow');
			$('#virtual_good_more').show('slow');
			getE('out_of_stock_1').checked = 'checked';
			getE('out_of_stock_2').disabled = 'disabled';
			getE('out_of_stock_3').disabled = 'disabled';
			getE('label_out_of_stock_2').setAttribute('for', '');
			getE('label_out_of_stock_3').setAttribute('for', '');
		}
		else
		{
			$('#virtual_good').hide('slow');
			$('#virtual_good_more').hide('slow');
			getE('out_of_stock_2').disabled = false;
			getE('out_of_stock_3').disabled = false;
			getE('label_out_of_stock_2').setAttribute('for', 'out_of_stock_2');
			getE('label_out_of_stock_3').setAttribute('for', 'out_of_stock_3');
		}
	}

	function uploadFile()
	{
		$.ajaxFileUpload (
			{
				url:'./uploadProductFile.php',
				secureuri:false,
				fileElementId:'virtual_product_file',
				dataType: 'xml',

				success: function (data, status)
				{
					data = data.getElementsByTagName('return')[0];
					var result = data.getAttribute("result");
					var msg = data.getAttribute("msg");
					var fileName = data.getAttribute("filename");

					if (result == "error")
					{
						$("#upload-confirmation").html('<p>error: ' + msg + '</p>');
					}
					else
					{
						$('#virtual_product_file').remove();
						$('#virtual_product_file_label').hide();
						$('#file_missing').hide();
						new_href = $('#delete_downloadable_product').attr('href').replace('%26deleteVirtualProduct%3Dtrue', '%26file%3D'+msg+'%26deleteVirtualProduct%3Dtrue');
						$('#delete_downloadable_product').attr('href', new_href);
						$('#delete_downloadable_product').show();
						$('#virtual_product_name').attr('value', fileName);
						$('#upload-confirmation').html(
							'<a class="link" href="get-file-admin.php?file='+msg+'&filename='+fileName+'"><?php 
        echo $this->l('The file');
        ?>
&nbsp;"' + fileName + '"&nbsp;<?php 
        echo $this->l('has successfully been uploaded');
        ?>
</a>' +
							'<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="' + msg + '" />');
					}
				}
			}
		);
	}

	//]]>
	</script>
	<?php 
        echo '
		<script type="text/javascript" src="../js/price.js"></script>
		<script type="text/javascript">
			var newLabel = \'' . $this->l('New label') . '\';
			var choose_language = \'' . $this->l('Choose language:') . '\';
			var required = \'' . $this->l('required') . '\';
			var customizationUploadableFileNumber = ' . (int) $this->getFieldValue($obj, 'uploadable_files') . ';
			var customizationTextFieldNumber = ' . (int) $this->getFieldValue($obj, 'text_fields') . ';
			var uploadableFileLabel = 0;
			var textFieldLabel = 0;
		</script>';
        ?>
	<tr>
		<td colspan="2">
			<p><input type="checkbox" id="is_virtual_good" name="is_virtual_good" value="true" onclick="toggleVirtualProduct(this);" <?php 
        if (($productDownload->id or Tools::getValue('is_virtual_good') == 'true') and $productDownload->active) {
            echo 'checked="checked"';
        }
        ?>
 />
			<label for="is_virtual_good" class="t bold" style="color: black;"><?php 
        echo $this->l('Is this a downloadable product?');
        ?>
</label></p>
			<div id="virtual_good" <?php 
        if (!$productDownload->id or !$productDownload->active) {
            echo 'style="display:none;"';
        }
        ?>
 >
	<?php 
        if (!ProductDownload::checkWritableDir()) {
            ?>
		<p class="alert">
			<?php 
            echo $this->l('Your download repository is not writable.');
            ?>
<br/>
			<?php 
            echo realpath(_PS_DOWNLOAD_DIR_);
            ?>
		</p>
	<?php 
        } else {
            ?>
			<?php 
            if ($productDownload->id) {
                echo '<input type="hidden" id="virtual_product_id" name="virtual_product_id" value="' . $productDownload->id . '" />';
            }
            ?>
				<p class="block">
	<?php 
            if (!$productDownload->checkFile()) {
                ?>

				<div style="padding:5px;width:50%;float:left;margin-right:20px;border-right:1px solid #E0D0B1">
		<?php 
                if ($productDownload->id) {
                    ?>
					<p class="alert" id="file_missing">
						<?php 
                    echo $this->l('This product is missing');
                    ?>
:<br/>
						<?php 
                    echo realpath(_PS_DOWNLOAD_DIR_) . '/' . $productDownload->physically_filename;
                    ?>
					</p>
		<?php 
                }
                ?>
					<p><?php 
                $max_upload = (int) ini_get('upload_max_filesize');
                $max_post = (int) ini_get('post_max_size');
                $upload_mb = min($max_upload, $max_post);
                echo $this->l('Your server\'s maximum upload file size is') . ':&nbsp;' . $upload_mb . $this->l('Mb');
                ?>
</p>
					<?php 
                if (!strval(Tools::getValue('virtual_product_filename'))) {
                    ?>
					<label id="virtual_product_file_label" for="virtual_product_file" class="t"><?php 
                    echo $this->l('Upload a file');
                    ?>
</label>
					<p><input type="file" id="virtual_product_file" name="virtual_product_file" onchange="uploadFile();" /></p>
					<?php 
                }
                ?>
					<div id="upload-confirmation">
					<?php 
                if ($up_filename = strval(Tools::getValue('virtual_product_filename'))) {
                    ?>
						<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php 
                    echo $up_filename;
                    ?>
" />
					<?php 
                }
                ?>
					</div>
					<a id="delete_downloadable_product" style="display:none;" href="confirm.php?height=200&amp;width=300&amp;modal=true&amp;referer=<?php 
                echo rawurlencode($_SERVER['REQUEST_URI'] . '&deleteVirtualProduct=true');
                ?>
" class="thickbox red" title="<?php 
                echo $this->l('Delete this file');
                ?>
"><?php 
                echo $this->l('Delete this file');
                ?>
</a>
	<?php 
            } else {
                ?>
					<input type="hidden" id="virtual_product_filename" name="virtual_product_filename" value="<?php 
                echo $productDownload->physically_filename;
                ?>
" />
					<?php 
                echo $this->l('This is the link') . ':&nbsp;' . $productDownload->getHtmlLink(false, true);
                ?>
					<a href="confirm.php?height=200&amp;width=300&amp;modal=true&amp;referer=<?php 
                echo rawurlencode($_SERVER['REQUEST_URI'] . '&deleteVirtualProduct=true');
                ?>
" class="thickbox red" title="<?php 
                echo $this->l('Delete this file');
                ?>
"><?php 
                echo $this->l('Delete this file');
                ?>
</a>
	<?php 
            }
            // check if file exists
            ?>
				</p>
				<p class="block">
					<label for="virtual_product_name" class="t"><?php 
            echo $this->l('Filename');
            ?>
</label>
					<input type="text" id="virtual_product_name" name="virtual_product_name" style="width:200px" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->display_filename : htmlentities(Tools::getValue('virtual_product_name'), ENT_COMPAT, 'UTF-8');
            ?>
" />
					<span class="hint" name="help_box" style="display:none;"><?php 
            echo $this->l('The full filename with its extension (e.g., Book.pdf)');
            ?>
</span>
				</p>

				</div>
				<div id="virtual_good_more" style="<?php 
            if (!$productDownload->id or !$productDownload->active) {
                echo 'display:none;';
            }
            ?>
padding:5px;width:40%;float:left;margin-left:10px">

				<p class="block">
					<label for="virtual_product_nb_downloable" class="t"><?php 
            echo $this->l('Number of downloads');
            ?>
</label>
					<input type="text" id="virtual_product_nb_downloable" name="virtual_product_nb_downloable" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->nb_downloadable : htmlentities(Tools::getValue('virtual_product_nb_downloable'), ENT_COMPAT, 'UTF-8');
            ?>
" class="" size="6" />
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('Number of authorized downloads per customer');
            ?>
</span>
				</p>
				<p class="block">
					<label for="virtual_product_expiration_date" class="t"><?php 
            echo $this->l('Expiration date');
            ?>
</label>
					<input type="text" id="virtual_product_expiration_date" name="virtual_product_expiration_date" value="<?php 
            echo $productDownload->id > 0 ? (!empty($productDownload->date_expiration) and $productDownload->date_expiration != '0000-00-00 00:00:00') ? date('Y-m-d', strtotime($productDownload->date_expiration)) : '' : htmlentities(Tools::getValue('virtual_product_expiration_date'), ENT_COMPAT, 'UTF-8');
            ?>
" size="11" maxlength="10" autocomplete="off" /> <?php 
            echo $this->l('Format: YYYY-MM-DD');
            ?>
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('No expiration date if you leave this blank');
            ?>
</span>
				</p>
				<p class="block">
					<label for="virtual_product_nb_days" class="t"><?php 
            echo $this->l('Number of days');
            ?>
</label>
					<input type="text" id="virtual_product_nb_days" name="virtual_product_nb_days" value="<?php 
            echo $productDownload->id > 0 ? $productDownload->nb_days_accessible : htmlentities(Tools::getValue('virtual_product_nb_days'), ENT_COMPAT, 'UTF-8');
            ?>
" class="" size="4" /><sup> *</sup>
					<span class="hint" name="help_box" style="display:none"><?php 
            echo $this->l('How many days this file can be accessed by customers');
            ?>
 - <em>(<?php 
            echo $this->l('set to zero for unlimited access');
            ?>
)</em></span>
				</p>
				</div>
	<?php 
        }
        // check if download directory is writable
        ?>
			</div>
		</td>
	</tr>
	<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
	<script type="text/javascript">
		if ($('#is_virtual_good').attr('checked'))
		{
			$('#virtual_good').show('slow');
			$('#virtual_good_more').show('slow');
		}
	</script>

<?php 
        echo '
					<tr>
						<td class="col-left">' . $this->l('Pre-tax wholesale price:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" name="wholesale_price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'wholesale_price'), ENT_COMPAT, 'UTF-8') . '" onchange="this.value = this.value.replace(/,/g, \'.\');" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">' . $this->l('The wholesale price at which you bought this product') . '</span>
						</td>
					</tr>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Pre-tax retail price:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="priceTE" name="price" type="text" value="' . htmlentities($this->getFieldValue($obj, 'price'), ENT_COMPAT, 'UTF-8') . '" onchange="this.value = this.value.replace(/,/g, \'.\');" onkeyup="if (isArrowKey(event)) return; calcPriceTI();" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '<sup> *</sup>
							<span style="margin-left:2px">' . $this->l('The pre-tax retail price to sell this product') . '</span>
						</td>
					</tr>';
        $tax_rules_groups = TaxRulesGroup::getTaxRulesGroups(true);
        $taxesRatesByGroup = TaxRulesGroup::getAssociatedTaxRatesByIdCountry(Country::getDefaultCountryId());
        $ecotaxTaxRate = Tax::getProductEcotaxRate();
        echo '<script type="text/javascript">';
        echo 'noTax = ' . (Tax::excludeTaxeOption() ? 'true' : 'false'), ";\n";
        echo 'taxesArray = new Array ();' . "\n";
        echo 'taxesArray[0] = 0', ";\n";
        foreach ($tax_rules_groups as $tax_rules_group) {
            $tax_rate = array_key_exists($tax_rules_group['id_tax_rules_group'], $taxesRatesByGroup) ? $taxesRatesByGroup[$tax_rules_group['id_tax_rules_group']] : 0;
            echo 'taxesArray[' . $tax_rules_group['id_tax_rules_group'] . ']=' . $tax_rate . "\n";
        }
        echo '
						ecotaxTaxRate = ' . $ecotaxTaxRate / 100 . ';
					</script>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Tax rule:') . '</td>
						<td style="padding-bottom:5px;">
					<span ' . (Tax::excludeTaxeOption() ? 'style="display:none;"' : '') . '>
					 <select onChange="javascript:calcPriceTI(); unitPriceWithTax(\'unit\');" name="id_tax_rules_group" id="id_tax_rules_group" ' . (Tax::excludeTaxeOption() ? 'disabled="disabled"' : '') . '>
						 <option value="0">' . $this->l('No Tax') . '</option>';
        foreach ($tax_rules_groups as $tax_rules_group) {
            echo '<option value="' . $tax_rules_group['id_tax_rules_group'] . '" ' . ($this->getFieldValue($obj, 'id_tax_rules_group') == $tax_rules_group['id_tax_rules_group'] ? ' selected="selected"' : '') . '>' . Tools::htmlentitiesUTF8($tax_rules_group['name']) . '</option>';
        }
        echo '</select>

				<a href="?tab=AdminTaxRulesGroup&addtax_rules_group&token=' . Tools::getAdminToken('AdminTaxRulesGroup' . (int) Tab::getIdFromClassName('AdminTaxRulesGroup') . (int) $cookie->id_employee) . '&id_product=' . (int) $obj->id . '" onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');"><img src="../img/admin/add.gif" alt="' . $this->l('Create') . '" title="' . $this->l('Create') . '" /> <b>' . $this->l('Create') . '</b></a></span>
				';
        if (Tax::excludeTaxeOption()) {
            echo '<span style="margin-left:10px; color:red;">' . $this->l('Taxes are currently disabled') . '</span> (<b><a href="index.php?tab=AdminTaxes&token=' . Tools::getAdminToken('AdminTaxes' . (int) Tab::getIdFromClassName('AdminTaxes') . (int) $cookie->id_employee) . '">' . $this->l('Tax options') . '</a></b>)';
            echo '<input type="hidden" value="' . (int) $this->getFieldValue($obj, 'id_tax_rules_group') . '" name="id_tax_rules_group" />';
        }
        echo '</td>
					</tr>
				';
        if (Configuration::get('PS_USE_ECOTAX')) {
            echo '
					<tr>
						<td class="col-left">' . $this->l('Eco-tax (tax incl.):') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<input size="11" maxlength="14" id="ecotax" name="ecotax" type="text" value="' . $this->getFieldValue($obj, 'ecotax') . '" onkeyup="if (isArrowKey(event))return; calcPriceTE(); this.value = this.value.replace(/,/g, \'.\'); if (parseInt(this.value) > getE(\'priceTE\').value) this.value = getE(\'priceTE\').value; if (isNaN(this.value)) this.value = 0;" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '
							<span style="margin-left:10px">(' . $this->l('already included in price') . ')</span>
						</td>
					</tr>';
        }
        if ($default_country->display_tax_label) {
            echo '
						<tr ' . (Tax::excludeTaxeOption() ? 'style="display:none"' : '') . '>
							<td class="col-left">' . $this->l('Retail price with tax:') . '</td>
							<td style="padding-bottom:5px;">
								' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="priceTI" type="text" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return;  calcPriceTE();" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '
							</td>
						</tr>';
        } else {
            echo '<input size="11" maxlength="14" id="priceTI" type="hidden" value="" onchange="noComma(\'priceTI\');" onkeyup="if (isArrowKey(event)) return;  calcPriceTE();" />';
        }
        echo '
					<tr id="tr_unit_price">
						<td class="col-left">' . $this->l('Unit price without tax:') . '</td>
						<td style="padding-bottom:5px;">
							' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . ' <input size="11" maxlength="14" id="unit_price" name="unit_price" type="text" value="' . ($this->getFieldValue($obj, 'unit_price_ratio') != 0 ? Tools::ps_round($this->getFieldValue($obj, 'price') / $this->getFieldValue($obj, 'unit_price_ratio'), 2) : 0) . '" onkeyup="if (isArrowKey(event)) return ;this.value = this.value.replace(/,/g, \'.\'); unitPriceWithTax(\'unit\');"/>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . $this->l('per') . ' <input size="6" maxlength="10" id="unity" name="unity" type="text" value="' . (Validate::isCleanHtml($this->getFieldValue($obj, 'unity')) ? htmlentities($this->getFieldValue($obj, 'unity'), ENT_QUOTES, 'UTF-8') : '') . '" onkeyup="if (isArrowKey(event)) return ;unitySecond();" onchange="unitySecond();"/>' . (Configuration::get('PS_TAX') && $default_country->display_tax_label ? '<span style="margin-left:15px">' . $this->l('or') . ' ' . ($currency->format % 2 != 0 ? ' ' . $currency->sign : '') . '<span id="unit_price_with_tax">0.00</span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . $this->l('per') . ' <span id="unity_second">' . (Validate::isCleanHtml($this->getFieldValue($obj, 'unity')) ? htmlentities($this->getFieldValue($obj, 'unity'), ENT_QUOTES, 'UTF-8') : '') . '</span> ' . $this->l('with tax') : '') . '</span>
							<p>' . $this->l('Eg. $15 per Lb') . '</p>
						</td>
					</tr>
					<tr>
						<td class="col-left">&nbsp;</td>
						<td style="padding-bottom:5px;">
							<input type="checkbox" name="on_sale" id="on_sale" style="padding-top: 5px;" ' . ($this->getFieldValue($obj, 'on_sale') ? 'checked="checked"' : '') . 'value="1" />&nbsp;<label for="on_sale" class="t">' . $this->l('Display "on sale" icon on product page and text on product listing') . '</label>
						</td>
					</tr>
					<tr>
						<td class="col-left"><b>' . $this->l('Final retail price:') . '</b></td>
						<td style="padding-bottom:5px;">
							<span style="' . ($default_country->display_tax_label ? '' : 'display:none') . '">
							' . ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<span id="finalPrice" style="font-weight: bold;"></span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . '<span' . (!Configuration::get('PS_TAX') ? ' style="display:none;"' : '') . '> (' . $this->l('tax incl.') . ')</span>
							</span>
							<span' . (!Configuration::get('PS_TAX') ? ' style="display:none;"' : '') . '>';
        if ($default_country->display_tax_label) {
            echo ' / ';
        }
        echo ($currency->format % 2 != 0 ? $currency->sign . ' ' : '') . '<span id="finalPriceWithoutTax" style="font-weight: bold;"></span>' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '') . ' ' . ($default_country->display_tax_label ? '(' . $this->l('tax excl.') . ')' : '') . '</span>
						</td>
					</tr>
					<tr>
						<td class="col-left">&nbsp;</td>
						<td>
							<div class="hint clear" style="display: block;width: 70%;">' . $this->l('You can define many discounts and specific price rules in the Prices tab') . '</div>
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>';
        if ((int) Configuration::get('PS_STOCK_MANAGEMENT')) {
            if (!$has_attribute) {
                if ($obj->id) {
                    echo '
							<tr><td class="col-left">' . $this->l('Stock Movement:') . '</td>
								<td style="padding-bottom:5px;">
									<select id="id_mvt_reason" name="id_mvt_reason">
										<option value="-1">--</option>';
                    $reasons = StockMvtReason::getStockMvtReasons((int) $cookie->id_lang);
                    foreach ($reasons as $reason) {
                        echo '<option rel="' . $reason['sign'] . '" value="' . $reason['id_stock_mvt_reason'] . '" ' . (Configuration::get('PS_STOCK_MVT_REASON_DEFAULT') == $reason['id_stock_mvt_reason'] ? 'selected="selected"' : '') . '>' . $reason['name'] . '</option>';
                    }
                    echo '</select>
									<input id="mvt_quantity" type="text" name="mvt_quantity" size="3" maxlength="10" value="0"/>&nbsp;&nbsp;
									<span style="display:none;" id="mvt_sign"></span>
								</td>
							</tr>
							<tr>
								<td class="col-left">&nbsp;</td>
								<td>
									<div class="hint clear" style="display: block;width: 70%;">' . $this->l('Choose the reason and enter the quantity that you want to increase or decrease in your stock') . '</div>
								</td>
							</tr>';
                } else {
                    echo '<tr><td class="col-left">' . $this->l('Initial stock:') . '</td>
									<td style="padding-bottom:5px;">
										<input size="3" maxlength="10" name="quantity" type="text" value="0" />
									</td>';
                }
                echo '<tr>
								<td class="col-left">' . $this->l('Minimum quantity:') . '</td>
									<td style="padding-bottom:5px;">
										<input size="3" maxlength="10" name="minimal_quantity" id="minimal_quantity" type="text" value="' . ($this->getFieldValue($obj, 'minimal_quantity') ? $this->getFieldValue($obj, 'minimal_quantity') : 1) . '" />
										<p>' . $this->l('The minimum quantity to buy this product (set to 1 to disable this feature)') . '</p>
									</td>
								</tr>';
            }
            if ($obj->id) {
                echo '
							<tr><td class="col-left">' . $this->l('Quantity in stock:') . '</td>
								<td style="padding-bottom:5px;"><b>' . $qty . '</b><input type="hidden" name="quantity" value="' . $qty . '" /></td>
							</tr>
						';
            }
            if ($has_attribute) {
                echo '<tr>
								<td class="col-left">&nbsp;</td>
								<td>
									<div class="hint clear" style="display: block;width: 70%;">' . $this->l('You used combinations, for this reason you cannot edit your stock quantity here, but in the Combinations tab') . '</div>
								</td>
							</tr>';
            }
        } else {
            echo '<tr>
							<td colspan="2">' . $this->l('The stock management is disabled') . '</td>
						</tr>';
            echo '
						<tr>
							<td class="col-left">' . $this->l('Minimum quantity:') . '</td>
							<td style="padding-bottom:5px;">
								<input size="3" maxlength="10" name="minimal_quantity" id="minimal_quantity" type="text" value="' . ($this->getFieldValue($obj, 'minimal_quantity') ? $this->getFieldValue($obj, 'minimal_quantity') : 1) . '" />
								<p>' . $this->l('The minimum quantity to buy this product (set to 1 to disable this feature)') . '</p>
							</td>
						</tr>
					';
        }
        echo '
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
					<tr>
						<td class="col-left">' . $this->l('Additional shipping cost:') . '</td>
						<td style="padding-bottom:5px;">
							<input type="text" name="additional_shipping_cost" value="' . Tools::safeOutput($this->getFieldValue($obj, 'additional_shipping_cost')) . '" />' . ($currency->format % 2 == 0 ? ' ' . $currency->sign : '');
        if ($default_country->display_tax_label) {
            echo ' (' . $this->l('tax excl.') . ')';
        }
        echo '<p>' . $this->l('Carrier tax will be applied.') . '</p>
						</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Displayed text when in-stock:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
								<input size="30" type="text" id="available_now_' . $language['id_lang'] . '" name="available_now_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_now', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" />
								<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        echo '			</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Displayed text when allowed to be back-ordered:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div  class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
								<input size="30" type="text" id="available_later_' . $language['id_lang'] . '" name="available_later_' . $language['id_lang'] . '"
								value="' . stripslashes(htmlentities($this->getFieldValue($obj, 'available_later', $language['id_lang']), ENT_COMPAT, 'UTF-8')) . '" />
								<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
							</div>';
        }
        echo '	</td>
					</tr>

					<script type="text/javascript">
						calcPriceTI();
					</script>

					<tr>
						<td class="col-left">' . $this->l('When out of stock:') . '</td>
						<td style="padding-bottom:5px;">
							<input type="radio" name="out_of_stock" id="out_of_stock_1" value="0" ' . ((int) $this->getFieldValue($obj, 'out_of_stock') == 0 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_1" class="t" id="label_out_of_stock_1">' . $this->l('Deny orders') . '</label>
							<br /><input type="radio" name="out_of_stock" id="out_of_stock_2" value="1" ' . ($this->getFieldValue($obj, 'out_of_stock') == 1 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_2" class="t" id="label_out_of_stock_2">' . $this->l('Allow orders') . '</label>
							<br /><input type="radio" name="out_of_stock" id="out_of_stock_3" value="2" ' . ($this->getFieldValue($obj, 'out_of_stock') == 2 ? 'checked="checked"' : '') . '/> <label for="out_of_stock_3" class="t" id="label_out_of_stock_3">' . $this->l('Default:') . ' <i>' . $this->l((int) Configuration::get('PS_ORDER_OUT_OF_STOCK') ? 'Allow orders' : 'Deny orders') . '</i> (' . $this->l('as set in') . ' <a href="index.php?tab=AdminPPreferences&token=' . Tools::getAdminToken('AdminPPreferences' . (int) Tab::getIdFromClassName('AdminPPreferences') . (int) $cookie->id_employee) . '"  onclick="return confirm(\'' . $this->l('Are you sure you want to delete entered product information?', __CLASS__, true, false) . '\');">' . $this->l('Preferences') . '</a>)</label>
						</td>
					</tr>
					<tr>
						<td colspan="2" style="padding-bottom:5px;">
							<hr style="width:100%;" />
						</td>
					</tr>
					<tr>
						<td class="col-left"><label for="id_category_default" class="t">' . $this->l('Default category:') . '</label></td>
						<td>
						<div id="no_default_category" style="color: red;font-weight: bold;display: none;">' . $this->l('Please check a category in order to select the default category.') . '</div>
						<script type="text/javascript">
							var post_selected_cat;
						</script>';
        $default_category = Tools::getValue('id_category', 1);
        if (!$obj->id) {
            $selectedCat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->_defaultFormLanguage);
            echo '
							<script type="text/javascript">
								post_selected_cat = \'' . implode(',', array_keys($selectedCat)) . '\';
							</script>';
        } else {
            if (Tools::isSubmit('categoryBox')) {
                $selectedCat = Category::getCategoryInformations(Tools::getValue('categoryBox', array($default_category)), $this->_defaultFormLanguage);
            } else {
                $selectedCat = Product::getProductCategoriesFull($obj->id, $this->_defaultFormLanguage);
            }
        }
        echo '<select id="id_category_default" name="id_category_default">';
        foreach ($selectedCat as $cat) {
            echo '<option value="' . $cat['id_category'] . '" ' . ($obj->id_category_default == $cat['id_category'] ? 'selected' : '') . '>' . $cat['name'] . '</option>';
        }
        echo '</select>
						</td>
					</tr>
					<tr id="tr_categories">
						<td colspan="2">
						';
        // Translations are not automatic for the moment ;)
        $trads = array('Home' => $this->l('Home'), 'selected' => $this->l('selected'), 'Collapse All' => $this->l('Collapse All'), 'Expand All' => $this->l('Expand All'), 'Check All' => $this->l('Check All'), 'Uncheck All' => $this->l('Uncheck All'));
        echo Helper::renderAdminCategorieTree($trads, $selectedCat) . '
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
					<tr><td colspan="2">
						<span onclick="$(\'#seo\').slideToggle();" style="cursor: pointer"><img src="../img/admin/arrow.gif" alt="' . $this->l('SEO') . '" title="' . $this->l('SEO') . '" style="float:left; margin-right:5px;"/>' . $this->l('Click here to improve product\'s rank in search engines (SEO)') . '</span><br />
						<div id="seo" style="display: none; padding-top: 15px;">
							<table>
								<tr>
									<td class="col-left">' . $this->l('Meta title:') . '</td>
									<td class="translatable">';
        foreach ($this->_languages as $language) {
            echo '					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_title_' . $language['id_lang'] . '" name="meta_title_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_title', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        echo '						<p class="clear">' . $this->l('Product page title; leave blank to use product name') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Meta description:') . '</td>
									<td class="translatable">';
        foreach ($this->_languages as $language) {
            echo '					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_description_' . $language['id_lang'] . '" name="meta_description_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_description', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        echo '						<p class="clear">' . $this->l('A single sentence for HTML header') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Meta keywords:') . '</td>
									<td class="translatable">';
        foreach ($this->_languages as $language) {
            echo '					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="meta_keywords_' . $language['id_lang'] . '" name="meta_keywords_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'meta_keywords', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" />
											<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        echo '						<p class="clear">' . $this->l('Keywords for HTML header, separated by a comma') . '</p>
									</td>
								</tr>
								<tr>
									<td class="col-left">' . $this->l('Friendly URL:') . '</td>
									<td class="translatable">';
        foreach ($this->_languages as $language) {
            echo '					<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
											<input size="55" type="text" id="link_rewrite_' . $language['id_lang'] . '" name="link_rewrite_' . $language['id_lang'] . '"
											value="' . htmlentities($this->getFieldValue($obj, 'link_rewrite', $language['id_lang']), ENT_COMPAT, 'UTF-8') . '" onkeyup="if (isArrowKey(event)) return ;updateFriendlyURL();" onchange="updateFriendlyURL();" /><sup> *</sup>
											<span class="hint" name="help_box">' . $this->l('Only letters and the "less" character are allowed') . '<span class="hint-pointer">&nbsp;</span></span>
										</div>';
        }
        echo '						<p class="clear" style="padding:10px 0 0 0">' . '<a style="cursor:pointer" class="button" onmousedown="updateFriendlyURLByName();">' . $this->l('Generate') . '</a>&nbsp;' . $this->l('Friendly-url from product\'s name.') . '<br /><br />';
        echo '						' . $this->l('Product link will look like this:') . ' ' . (Configuration::get('PS_SSL_ENABLED') ? 'https://' : 'http://') . $_SERVER['SERVER_NAME'] . '/<b>id_product</b>-<span id="friendly-url"></span>.html</p>
									</td>
								</tr>';
        echo '</td></tr></table>
						</div>
					</td></tr>
					<tr><td colspan="2" style="padding-bottom:5px;"><hr style="width:100%;" /></td></tr>
					<tr>
						<td class="col-left">' . $this->l('Short description:') . '<br /><br /><i>(' . $this->l('appears in the product lists and on the top of the product page') . ')</i></td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . ';float: left;">
								<textarea class="rte" cols="100" rows="10" id="description_short_' . $language['id_lang'] . '" name="description_short_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description_short', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea>
							</div>';
        }
        echo '		</td>
					</tr>
					<tr>
						<td class="col-left">' . $this->l('Description:') . '<br /><br /><i>(' . $this->l('appears in the body of the product page') . ')</i></td>
						<td style="padding-bottom:5px;" class="translatable">';
        foreach ($this->_languages as $language) {
            echo '		<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . ';float: left;">
								<textarea class="rte" cols="100" rows="20" id="description_' . $language['id_lang'] . '" name="description_' . $language['id_lang'] . '">' . htmlentities(stripslashes($this->getFieldValue($obj, 'description', $language['id_lang'])), ENT_COMPAT, 'UTF-8') . '</textarea>
							</div>';
        }
        echo '		</td>
					</tr>';
        echo '
					<tr>
						<td class="col-left">' . $this->l('Tags:') . '</td>
						<td style="padding-bottom:5px;" class="translatable">';
        if ($obj->id) {
            $obj->tags = Tag::getProductTags((int) $obj->id);
        }
        foreach ($this->_languages as $language) {
            echo '<div class="lang_' . $language['id_lang'] . '" style="display: ' . ($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none') . '; float: left;">
							<input size="55" type="text" id="tags_' . $language['id_lang'] . '" name="tags_' . $language['id_lang'] . '"
							value="' . htmlentities(Tools::getValue('tags_' . $language['id_lang'], $obj->getTags($language['id_lang'], true)), ENT_COMPAT, 'UTF-8') . '" />
							<span class="hint" name="help_box">' . $this->l('Forbidden characters:') . ' !<>;?=+#"&deg;{}_$%<span class="hint-pointer">&nbsp;</span></span>
						  </div>';
        }
        echo '	<p class="clear">' . $this->l('Tags separated by commas (e.g., dvd, dvd player, hifi)') . '</p>
						</td>
					</tr>';
        $accessories = Product::getAccessoriesLight((int) $cookie->id_lang, $obj->id);
        if ($postAccessories = Tools::getValue('inputAccessories')) {
            $postAccessoriesTab = explode('-', Tools::getValue('inputAccessories'));
            foreach ($postAccessoriesTab as $accessoryId) {
                if (!$this->haveThisAccessory($accessoryId, $accessories) and $accessory = Product::getAccessoryById($accessoryId)) {
                    $accessories[] = $accessory;
                }
            }
        }
        echo '
					<tr>
						<td class="col-left">' . $this->l('Accessories:') . '<br /><br /><i>' . $this->l('(Do not forget to Save the product afterward)') . '</i></td>
						<td style="padding-bottom:5px;">
							<div id="divAccessories">';
        foreach ($accessories as $accessory) {
            echo htmlentities($accessory['name'], ENT_COMPAT, 'UTF-8') . (!empty($accessory['reference']) ? ' (' . $accessory['reference'] . ')' : '') . ' <span onclick="delAccessory(' . $accessory['id_product'] . ');" style="cursor: pointer;"><img src="../img/admin/delete.gif" class="middle" alt="" /></span><br />';
        }
        echo '</div>
							<input type="hidden" name="inputAccessories" id="inputAccessories" value="';
        foreach ($accessories as $accessory) {
            echo (int) $accessory['id_product'] . '-';
        }
        echo '" />
							<input type="hidden" name="nameAccessories" id="nameAccessories" value="';
        foreach ($accessories as $accessory) {
            echo htmlentities($accessory['name'], ENT_COMPAT, 'UTF-8') . '¤';
        }
        echo '" />
							<script type="text/javascript">
								var formProduct;
								var accessories = new Array();
							</script>

							<link rel="stylesheet" type="text/css" href="' . __PS_BASE_URI__ . 'css/jquery.autocomplete.css" />
							<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/jquery/jquery.autocomplete.js"></script>
							<div id="ajax_choose_product" style="padding:6px; padding-top:2px; width:600px;">
								<p class="clear">' . $this->l('Begin typing the first letters of the product name, then select the product from the drop-down list:') . '</p>
								<input type="text" value="" id="product_autocomplete_input" />
								<img onclick="$(this).prev().search();" style="cursor: pointer;" src="../img/admin/add.gif" alt="' . $this->l('Add an accessory') . '" title="' . $this->l('Add an accessory') . '" />
							</div>
							<script type="text/javascript">
								urlToCall = null;
								/* function autocomplete */
								$(function() {
									$(\'#product_autocomplete_input\')
										.autocomplete(\'ajax_products_list.php\', {
											minChars: 1,
											autoFill: true,
											max:20,
											matchContains: true,
											mustMatch:true,
											scroll:false,
											cacheLength:0,
											formatItem: function(item) {
												return item[1]+\' - \'+item[0];
											}
										}).result(addAccessory);
									$(\'#product_autocomplete_input\').setOptions({
										extraParams: {excludeIds : getAccessorieIds()}
									});
								});
							</script>
						</td>
					</tr>
					<tr><td colspan="2" style="padding-bottom:10px;"><hr style="width:100%;" /></td></tr>
					<tr>
						<td colspan="2" style="text-align:center;">
							<input type="submit" value="' . $this->l('Save') . '" name="submitAdd' . $this->table . '" class="button" />
							&nbsp;<input type="submit" value="' . $this->l('Save and stay') . '" name="submitAdd' . $this->table . 'AndStay" class="button" /></td>
					</tr>
				</table>
			<br />
			</div>';
        // TinyMCE
        global $cookie;
        $iso = Language::getIsoById((int) $cookie->id_lang);
        $isoTinyMCE = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
        $ad = dirname($_SERVER["PHP_SELF"]);
        echo '
			<script type="text/javascript">
			var iso = \'' . $isoTinyMCE . '\' ;
			var pathCSS = \'' . _THEME_CSS_DIR_ . '\' ;
			var ad = \'' . $ad . '\' ;
			</script>
			<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tiny_mce/tiny_mce.js"></script>
			<script type="text/javascript" src="' . __PS_BASE_URI__ . 'js/tinymce.inc.js"></script>
			<script type="text/javascript">
					toggleVirtualProduct(getE(\'is_virtual_good\'));
					unitPriceWithTax(\'unit\');
			</script>';
        $categoryBox = Tools::getValue('categoryBox', array());
    }
 private function agileLoadProduct($id_product)
 {
     ${"GLOBALS"}["qjcfdxciaovg"] = "id_product";
     $usvlhhp = "prod";
     ${$usvlhhp} = new Product(${${"GLOBALS"}["yywbslr"]}, true);
     $prod->price = (double) Db::getInstance()->getValue("SELECT price FROM " . _DB_PREFIX_ . "product WHERE id_product=" . (int) ${${"GLOBALS"}["yywbslr"]});
     $prod->unit_price = $prod->unit_price_ratio != 0 ? $prod->price / $prod->unit_price_ratio : 0;
     ${"GLOBALS"}["ehfbxhwhf"] = "prod";
     if ($this->product_menu == 1 && ${${"GLOBALS"}["qjcfdxciaovg"]} > 0) {
         ${"GLOBALS"}["ptammewesp"] = "id_product";
         $prod->tags = Tag::getProductTags(${${"GLOBALS"}["ptammewesp"]});
     }
     return ${${"GLOBALS"}["ehfbxhwhf"]};
 }
示例#8
0
 public function hookExtraRight($params)
 {
     if (!Configuration::get('iqittag_hook')) {
         $id_product = (int) Tools::getValue('id_product');
         if (!$this->isCached('iqitproducttags.tpl', $this->getCacheId($id_product))) {
             $tags = Tag::getProductTags($id_product);
             if (is_array($tags)) {
                 $this->smarty->assign(array('tags' => $tags[1]));
             }
         }
         return $this->display(__FILE__, 'iqitproducttags.tpl', $this->getCacheId($id_product));
     }
 }
    public function productImport()
    {
        $this->receiveTab();
        $handle = $this->openCsvFile();
        $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
        $id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
        if (!Validate::isUnsignedId($id_lang)) {
            $id_lang = $default_language_id;
        }
        AdminImportController::setLocale();
        $shop_ids = Shop::getCompleteListOfShopsID();
        for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
            if (Tools::getValue('convert')) {
                $line = $this->utf8EncodeArray($line);
            }
            $info = AdminImportController::getMaskedRow($line);
            if (Tools::getValue('forceIDs') && isset($info['id']) && (int) $info['id']) {
                $product = new Product((int) $info['id']);
            } elseif (Tools::getValue('match_ref') && array_key_exists('reference', $info)) {
                $datas = Db::getInstance()->getRow('
						SELECT p.`id_product`
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE p.`reference` = "' . pSQL($info['reference']) . '"
					');
                if (isset($datas['id_product']) && $datas['id_product']) {
                    $product = new Product((int) $datas['id_product']);
                } else {
                    $product = new Product();
                }
            } elseif (array_key_exists('id', $info) && (int) $info['id'] && Product::existsInDatabase((int) $info['id'], 'product')) {
                $product = new Product((int) $info['id']);
            } else {
                $product = new Product();
            }
            if (isset($product->id) && $product->id && Product::existsInDatabase((int) $product->id, 'product')) {
                $product->loadStockData();
                $category_data = Product::getProductCategories((int) $product->id);
                foreach ($category_data as $tmp) {
                    $product->category[] = $tmp;
                }
            }
            AdminImportController::setEntityDefaultValues($product);
            AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product);
            if (!Shop::isFeatureActive()) {
                $product->shop = 1;
            } elseif (!isset($product->shop) || empty($product->shop)) {
                $product->shop = implode($this->multiple_value_separator, Shop::getContextListShopID());
            }
            if (!Shop::isFeatureActive()) {
                $product->id_shop_default = 1;
            } else {
                $product->id_shop_default = (int) Context::getContext()->shop->id;
            }
            // link product to shops
            $product->id_shop_list = array();
            foreach (explode($this->multiple_value_separator, $product->shop) as $shop) {
                if (!empty($shop) && !is_numeric($shop)) {
                    $product->id_shop_list[] = Shop::getIdByName($shop);
                } elseif (!empty($shop)) {
                    $product->id_shop_list[] = $shop;
                }
            }
            if ((int) $product->id_tax_rules_group != 0) {
                if (Validate::isLoadedObject(new TaxRulesGroup($product->id_tax_rules_group))) {
                    $address = $this->context->shop->getAddress();
                    $tax_manager = TaxManagerFactory::getManager($address, $product->id_tax_rules_group);
                    $product_tax_calculator = $tax_manager->getTaxCalculator();
                    $product->tax_rate = $product_tax_calculator->getTotalRate();
                } else {
                    $this->addProductWarning('id_tax_rules_group', $product->id_tax_rules_group, Tools::displayError('Invalid tax rule group ID. You first need to create a group with this ID.'));
                }
            }
            if (isset($product->manufacturer) && is_numeric($product->manufacturer) && Manufacturer::manufacturerExists((int) $product->manufacturer)) {
                $product->id_manufacturer = (int) $product->manufacturer;
            } else {
                if (isset($product->manufacturer) && is_string($product->manufacturer) && !empty($product->manufacturer)) {
                    if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) {
                        $product->id_manufacturer = (int) $manufacturer;
                    } else {
                        $manufacturer = new Manufacturer();
                        $manufacturer->name = $product->manufacturer;
                        if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $manufacturer->add()) {
                            $product->id_manufacturer = (int) $manufacturer->id;
                        } else {
                            $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $manufacturer->name, isset($manufacturer->id) && !empty($manufacturer->id) ? $manufacturer->id : 'null');
                            $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                        }
                    }
                }
            }
            if (isset($product->supplier) && is_numeric($product->supplier) && Supplier::supplierExists((int) $product->supplier)) {
                $product->id_supplier = (int) $product->supplier;
            } else {
                if (isset($product->supplier) && is_string($product->supplier) && !empty($product->supplier)) {
                    if ($supplier = Supplier::getIdByName($product->supplier)) {
                        $product->id_supplier = (int) $supplier;
                    } else {
                        $supplier = new Supplier();
                        $supplier->name = $product->supplier;
                        $supplier->active = true;
                        if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $supplier->add()) {
                            $product->id_supplier = (int) $supplier->id;
                            $supplier->associateTo($product->id_shop_list);
                        } else {
                            $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $supplier->name, isset($supplier->id) && !empty($supplier->id) ? $supplier->id : 'null');
                            $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                        }
                    }
                }
            }
            if (isset($product->price_tex) && !isset($product->price_tin)) {
                $product->price = $product->price_tex;
            } else {
                if (isset($product->price_tin) && !isset($product->price_tex)) {
                    $product->price = $product->price_tin;
                    // If a tax is already included in price, withdraw it from price
                    if ($product->tax_rate) {
                        $product->price = (double) number_format($product->price / (1 + $product->tax_rate / 100), 6, '.', '');
                    }
                } else {
                    if (isset($product->price_tin) && isset($product->price_tex)) {
                        $product->price = $product->price_tex;
                    }
                }
            }
            if (isset($product->category) && is_array($product->category) && count($product->category)) {
                $product->id_category = array();
                // Reset default values array
                foreach ($product->category as $value) {
                    if (is_numeric($value)) {
                        if (Category::categoryExists((int) $value)) {
                            $product->id_category[] = (int) $value;
                        } else {
                            $category_to_create = new Category();
                            $category_to_create->id = (int) $value;
                            $category_to_create->name = AdminImportController::createMultiLangField($value);
                            $category_to_create->active = 1;
                            $category_to_create->id_parent = Configuration::get('PS_HOME_CATEGORY');
                            // Default parent is home for unknown category to create
                            $category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]);
                            $category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite);
                            if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $category_to_create->add()) {
                                $product->id_category[] = (int) $category_to_create->id;
                            } else {
                                $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $category_to_create->name[$default_language_id], isset($category_to_create->id) && !empty($category_to_create->id) ? $category_to_create->id : 'null');
                                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                            }
                        }
                    } else {
                        if (is_string($value) && !empty($value)) {
                            $category = Category::searchByName($id_lang, trim($value), true);
                            if ($category['id_category']) {
                                $product->id_category[] = (int) $category['id_category'];
                            } else {
                                $category_to_create = new Category();
                                if (!Shop::isFeatureActive()) {
                                    $category_to_create->id_shop_default = 1;
                                } else {
                                    $category_to_create->id_shop_default = (int) Context::getContext()->shop->id;
                                }
                                $category_to_create->name = AdminImportController::createMultiLangField(trim($value));
                                $category_to_create->active = 1;
                                $category_to_create->id_parent = (int) Configuration::get('PS_HOME_CATEGORY');
                                // Default parent is home for unknown category to create
                                $category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]);
                                $category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite);
                                if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $category_to_create->add()) {
                                    $product->id_category[] = (int) $category_to_create->id;
                                } else {
                                    $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $category_to_create->name[$default_language_id], isset($category_to_create->id) && !empty($category_to_create->id) ? $category_to_create->id : 'null');
                                    $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                                }
                            }
                        }
                    }
                }
            }
            $product->id_category_default = isset($product->id_category[0]) ? (int) $product->id_category[0] : '';
            $link_rewrite = is_array($product->link_rewrite) && isset($product->link_rewrite[$id_lang]) ? trim($product->link_rewrite[$id_lang]) : '';
            $valid_link = Validate::isLinkRewrite($link_rewrite);
            if (isset($product->link_rewrite[$id_lang]) && empty($product->link_rewrite[$id_lang]) || !$valid_link) {
                $link_rewrite = Tools::link_rewrite($product->name[$id_lang]);
                if ($link_rewrite == '') {
                    $link_rewrite = 'friendly-url-autogeneration-failed';
                }
            }
            if (!$valid_link) {
                $this->warnings[] = sprintf(Tools::displayError('Rewrite link for %1$s (ID: %2$s) was re-written as %3$s.'), $product->name[$id_lang], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null', $link_rewrite);
            }
            if (!Tools::getValue('match_ref') || !(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) {
                $product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite);
            }
            // replace the value of separator by coma
            if ($this->multiple_value_separator != ',') {
                if (is_array($product->meta_keywords)) {
                    foreach ($product->meta_keywords as &$meta_keyword) {
                        if (!empty($meta_keyword)) {
                            $meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword);
                        }
                    }
                }
            }
            // Convert comma into dot for all floating values
            foreach (Product::$definition['fields'] as $key => $array) {
                if ($array['type'] == Product::TYPE_FLOAT) {
                    $product->{$key} = str_replace(',', '.', $product->{$key});
                }
            }
            // Indexation is already 0 if it's a new product, but not if it's an update
            $product->indexed = 0;
            $res = false;
            $field_error = $product->validateFields(UNFRIENDLY_ERROR, true);
            $lang_field_error = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
            if ($field_error === true && $lang_field_error === true) {
                // check quantity
                if ($product->quantity == null) {
                    $product->quantity = 0;
                }
                // If match ref is specified && ref product && ref product already in base, trying to update
                if (Tools::getValue('match_ref') == 1 && $product->reference && $product->existsRefInDatabase($product->reference)) {
                    $datas = Db::getInstance()->getRow('
						SELECT product_shop.`date_add`, p.`id_product`
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE p.`reference` = "' . pSQL($product->reference) . '"
					');
                    $product->id = (int) $datas['id_product'];
                    $product->date_add = pSQL($datas['date_add']);
                    $res = $product->update();
                } else {
                    if ($product->id && Product::existsInDatabase((int) $product->id, 'product')) {
                        $datas = Db::getInstance()->getRow('
						SELECT product_shop.`date_add`
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE p.`id_product` = ' . (int) $product->id);
                        $product->date_add = pSQL($datas['date_add']);
                        $res = $product->update();
                    }
                }
                // If no id_product or update failed
                if (!$res) {
                    if (isset($product->date_add) && $product->date_add != '') {
                        $res = $product->add(false);
                    } else {
                        $res = $product->add();
                    }
                }
            }
            $shops = array();
            $product_shop = explode($this->multiple_value_separator, $product->shop);
            foreach ($product_shop as $shop) {
                if (empty($shop)) {
                    continue;
                }
                $shop = trim($shop);
                if (!empty($shop) && !is_numeric($shop)) {
                    $shop = Shop::getIdByName($shop);
                }
                if (in_array($shop, $shop_ids)) {
                    $shops[] = $shop;
                } else {
                    $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Shop is not valid'));
                }
            }
            if (empty($shops)) {
                $shops = Shop::getContextListShopID();
            }
            // If both failed, mysql error
            if (!$res) {
                $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
            } else {
                // Product supplier
                if (isset($product->id_supplier) && property_exists($product, 'supplier_reference')) {
                    $id_product_supplier = ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier);
                    if ($id_product_supplier) {
                        $product_supplier = new ProductSupplier((int) $id_product_supplier);
                    } else {
                        $product_supplier = new ProductSupplier();
                    }
                    $product_supplier->id_product = $product->id;
                    $product_supplier->id_product_attribute = 0;
                    $product_supplier->id_supplier = $product->id_supplier;
                    $product_supplier->product_supplier_price_te = $product->wholesale_price;
                    $product_supplier->product_supplier_reference = $product->supplier_reference;
                    $product_supplier->save();
                }
                // SpecificPrice (only the basic reduction feature is supported by the import)
                if (!Shop::isFeatureActive()) {
                    $info['shop'] = 1;
                } elseif (!isset($info['shop']) || empty($info['shop'])) {
                    $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
                }
                // Get shops for each attributes
                $info['shop'] = explode($this->multiple_value_separator, $info['shop']);
                $id_shop_list = array();
                foreach ($info['shop'] as $shop) {
                    if (!empty($shop) && !is_numeric($shop)) {
                        $id_shop_list[] = (int) Shop::getIdByName($shop);
                    } elseif (!empty($shop)) {
                        $id_shop_list[] = $shop;
                    }
                }
                if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) {
                    foreach ($id_shop_list as $id_shop) {
                        $specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
                        if (is_array($specific_price) && isset($specific_price['id_specific_price'])) {
                            $specific_price = new SpecificPrice((int) $specific_price['id_specific_price']);
                        } else {
                            $specific_price = new SpecificPrice();
                        }
                        $specific_price->id_product = (int) $product->id;
                        $specific_price->id_specific_price_rule = 0;
                        $specific_price->id_shop = $id_shop;
                        $specific_price->id_currency = 0;
                        $specific_price->id_country = 0;
                        $specific_price->id_group = 0;
                        $specific_price->price = -1;
                        $specific_price->id_customer = 0;
                        $specific_price->from_quantity = 1;
                        $specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
                        $specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
                        $specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
                        $specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
                        if (!$specific_price->save()) {
                            $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
                        }
                    }
                }
                if (isset($product->tags) && !empty($product->tags)) {
                    if (isset($product->id) && $product->id) {
                        $tags = Tag::getProductTags($product->id);
                        if (is_array($tags) && count($tags)) {
                            if (!empty($product->tags)) {
                                $product->tags = explode($this->multiple_value_separator, $product->tags);
                            }
                            if (is_array($product->tags) && count($product->tags)) {
                                foreach ($product->tags as $key => $tag) {
                                    if (!empty($tag)) {
                                        $product->tags[$key] = trim($tag);
                                    }
                                }
                                $tags[$id_lang] = $product->tags;
                                $product->tags = $tags;
                            }
                        }
                    }
                    // Delete tags for this id product, for no duplicating error
                    Tag::deleteTagsForProduct($product->id);
                    if (!is_array($product->tags) && !empty($product->tags)) {
                        $product->tags = AdminImportController::createMultiLangField($product->tags);
                        foreach ($product->tags as $key => $tags) {
                            $is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
                            if (!$is_tag_added) {
                                $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid'));
                                break;
                            }
                        }
                    } else {
                        foreach ($product->tags as $key => $tags) {
                            $str = '';
                            foreach ($tags as $one_tag) {
                                $str .= $one_tag . $this->multiple_value_separator;
                            }
                            $str = rtrim($str, $this->multiple_value_separator);
                            $is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
                            if (!$is_tag_added) {
                                $this->addProductWarning(Tools::safeOutput($info['name']), (int) $product->id, 'Invalid tag(s) (' . $str . ')');
                                break;
                            }
                        }
                    }
                }
                //delete existing images if "delete_existing_images" is set to 1
                if (isset($product->delete_existing_images)) {
                    if ((bool) $product->delete_existing_images) {
                        $product->deleteImages();
                    } else {
                        if (isset($product->image) && is_array($product->image) && count($product->image)) {
                            $product->deleteImages();
                        }
                    }
                }
                if (isset($product->image) && is_array($product->image) && count($product->image)) {
                    $product_has_images = (bool) Image::getImages($this->context->language->id, (int) $product->id);
                    foreach ($product->image as $key => $url) {
                        $url = trim($url);
                        $error = false;
                        if (!empty($url)) {
                            $url = str_replace(' ', '%20', $url);
                            $image = new Image();
                            $image->id_product = (int) $product->id;
                            $image->position = Image::getHighestPosition($product->id) + 1;
                            $image->cover = !$key && !$product_has_images ? true : false;
                            // file_exists doesn't work with HTTP protocol
                            if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add()) {
                                // associate image to selected shops
                                $image->associateTo($shops);
                                if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !Tools::getValue('regenerate'))) {
                                    $image->delete();
                                    $this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url);
                                }
                            } else {
                                $error = true;
                            }
                        } else {
                            $error = true;
                        }
                        if ($error) {
                            $this->warnings[] = sprintf(Tools::displayError('Product n°%1$d: the picture cannot be saved: %2$s'), $image->id_product, $url);
                        }
                    }
                }
                if (isset($product->id_category)) {
                    $product->updateCategories(array_map('intval', $product->id_category));
                }
                // Features import
                $features = get_object_vars($product);
                if (isset($features['features']) && !empty($features['features'])) {
                    foreach (explode($this->multiple_value_separator, $features['features']) as $single_feature) {
                        if (empty($single_feature)) {
                            continue;
                        }
                        $tab_feature = explode(':', $single_feature);
                        $feature_name = isset($tab_feature[0]) ? trim($tab_feature[0]) : '';
                        $feature_value = isset($tab_feature[1]) ? trim($tab_feature[1]) : '';
                        $position = isset($tab_feature[2]) ? (int) $tab_feature[2] : false;
                        $custom = isset($tab_feature[3]) ? (int) $tab_feature[3] : false;
                        if (!empty($feature_name) && !empty($feature_value)) {
                            $id_feature = (int) Feature::addFeatureImport($feature_name, $position);
                            $id_product = null;
                            if (Tools::getValue('forceIDs') || Tools::getValue('match_ref')) {
                                $id_product = (int) $product->id;
                            }
                            $id_feature_value = (int) FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom);
                            Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
                        }
                    }
                }
                // clean feature positions to avoid conflict
                Feature::cleanPositions();
            }
            // stock available
            if (Shop::isFeatureActive()) {
                foreach ($shops as $shop) {
                    StockAvailable::setQuantity((int) $product->id, 0, $product->quantity, (int) $shop);
                }
            } else {
                StockAvailable::setQuantity((int) $product->id, 0, $product->quantity, $this->context->shop->id);
            }
        }
        $this->closeCsvFile($handle);
    }
    function content_56139717aa65e8_72426751($_smarty_tpl)
    {
        if (!is_callable('smarty_modifier_date_format')) {
            include '/home/oobox/domains/oobox.stronazen.pl/public_html/xiaomipl/tools/smarty/plugins/modifier.date_format.php';
        }
        if (!is_callable('smarty_function_math')) {
            include '/home/oobox/domains/oobox.stronazen.pl/public_html/xiaomipl/tools/smarty/plugins/function.math.php';
        }
        if (!is_callable('smarty_function_cycle')) {
            include '/home/oobox/domains/oobox.stronazen.pl/public_html/xiaomipl/tools/smarty/plugins/function.cycle.php';
        }
        if (!is_callable('smarty_function_counter')) {
            include '/home/oobox/domains/oobox.stronazen.pl/public_html/xiaomipl/tools/smarty/plugins/function.counter.php';
        }
        echo $_smarty_tpl->getSubTemplate((string) $_smarty_tpl->tpl_vars['tpl_dir']->value . "./errors.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);
        ?>

<?php 
        if (count($_smarty_tpl->tpl_vars['errors']->value) == 0) {
            ?>
	<?php 
            if (!isset($_smarty_tpl->tpl_vars['priceDisplayPrecision']->value)) {
                ?>
		<?php 
                $_smarty_tpl->tpl_vars['priceDisplayPrecision'] = new Smarty_variable(2, null, 0);
                ?>
	<?php 
            }
            ?>
	<?php 
            if (!$_smarty_tpl->tpl_vars['priceDisplay']->value || $_smarty_tpl->tpl_vars['priceDisplay']->value == 2) {
                ?>
		<?php 
                $_smarty_tpl->tpl_vars['productPrice'] = new Smarty_variable($_smarty_tpl->tpl_vars['product']->value->getPrice(true, @constant('NULL'), 6), null, 0);
                ?>
		<?php 
                $_smarty_tpl->tpl_vars['productPriceWithoutReduction'] = new Smarty_variable($_smarty_tpl->tpl_vars['product']->value->getPriceWithoutReduct(false, @constant('NULL')), null, 0);
                ?>
	<?php 
            } elseif ($_smarty_tpl->tpl_vars['priceDisplay']->value == 1) {
                ?>
		<?php 
                $_smarty_tpl->tpl_vars['productPrice'] = new Smarty_variable($_smarty_tpl->tpl_vars['product']->value->getPrice(false, @constant('NULL'), 6), null, 0);
                ?>
		<?php 
                $_smarty_tpl->tpl_vars['productPriceWithoutReduction'] = new Smarty_variable($_smarty_tpl->tpl_vars['product']->value->getPriceWithoutReduct(true, @constant('NULL')), null, 0);
                ?>
	<?php 
            }
            ?>
<div itemscope itemtype="https://schema.org/Product">
	<meta itemprop="url" content="<?php 
            echo $_smarty_tpl->tpl_vars['link']->value->getProductLink($_smarty_tpl->tpl_vars['product']->value);
            ?>
">
	<div class="primary_block row">
		<?php 
            if (!$_smarty_tpl->tpl_vars['content_only']->value) {
                ?>
			<div class="container">
				<div class="top-hr"></div>
			</div>
		<?php 
            }
            ?>
		<?php 
            if (isset($_smarty_tpl->tpl_vars['adminActionDisplay']->value) && $_smarty_tpl->tpl_vars['adminActionDisplay']->value) {
                ?>
			<div id="admin-action" class="container">
				<p class="alert alert-info"><?php 
                echo smartyTranslate(array('s' => 'This product is not visible to your customers.'), $_smarty_tpl);
                ?>

					<input type="hidden" id="admin-action-product-id" value="<?php 
                echo $_smarty_tpl->tpl_vars['product']->value->id;
                ?>
" />
					<a id="publish_button" class="btn btn-default button button-small" href="#">
						<span><?php 
                echo smartyTranslate(array('s' => 'Publish'), $_smarty_tpl);
                ?>
</span>
					</a>
					<a id="lnk_view" class="btn btn-default button button-small" href="#">
						<span><?php 
                echo smartyTranslate(array('s' => 'Back'), $_smarty_tpl);
                ?>
</span>
					</a>
				</p>
				<p id="admin-action-result"></p>
			</div>
		<?php 
            }
            ?>
		<?php 
            if (isset($_smarty_tpl->tpl_vars['confirmation']->value) && $_smarty_tpl->tpl_vars['confirmation']->value) {
                ?>
			<p class="confirmation">
				<?php 
                echo $_smarty_tpl->tpl_vars['confirmation']->value;
                ?>

			</p>
		<?php 
            }
            ?>
		<!-- left infos-->
		<div class="pb-left-column col-xs-12 col-sm-4 col-md-6">
			<!-- product img-->
			<div id="image-block" class="clearfix">
				<?php 
            if ($_smarty_tpl->tpl_vars['product']->value->new) {
                ?>
					<span class="new-box">
						<span class="new-label"><?php 
                echo smartyTranslate(array('s' => 'New'), $_smarty_tpl);
                ?>
</span>
					</span>
				<?php 
            }
            ?>
				<?php 
            if ($_smarty_tpl->tpl_vars['product']->value->on_sale) {
                ?>
					<span class="sale-box no-print">
						<span class="sale-label"><?php 
                echo smartyTranslate(array('s' => 'Sale!'), $_smarty_tpl);
                ?>
</span>
					</span>
				<?php 
            } elseif ($_smarty_tpl->tpl_vars['product']->value->specificPrice && $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction'] && $_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value > $_smarty_tpl->tpl_vars['productPrice']->value) {
                ?>
					<span class="discount"><?php 
                echo smartyTranslate(array('s' => 'Reduced price!'), $_smarty_tpl);
                ?>
</span>
				<?php 
            }
            ?>
				<?php 
            if ($_smarty_tpl->tpl_vars['have_image']->value) {
                ?>
					<span id="view_full_size">
						<?php 
                if ($_smarty_tpl->tpl_vars['jqZoomEnabled']->value && $_smarty_tpl->tpl_vars['have_image']->value && !$_smarty_tpl->tpl_vars['content_only']->value) {
                    ?>
							<a class="jqzoom" title="<?php 
                    if (!empty($_smarty_tpl->tpl_vars['cover']->value['legend'])) {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['cover']->value['legend'], ENT_QUOTES, 'UTF-8', true);
                    } else {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->name, ENT_QUOTES, 'UTF-8', true);
                    }
                    ?>
" rel="gal1" href="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value->link_rewrite, $_smarty_tpl->tpl_vars['cover']->value['id_image'], 'thickbox_default'), ENT_QUOTES, 'UTF-8', true);
                    ?>
">
								<img itemprop="image" src="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value->link_rewrite, $_smarty_tpl->tpl_vars['cover']->value['id_image'], 'large_default'), ENT_QUOTES, 'UTF-8', true);
                    ?>
" title="<?php 
                    if (!empty($_smarty_tpl->tpl_vars['cover']->value['legend'])) {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['cover']->value['legend'], ENT_QUOTES, 'UTF-8', true);
                    } else {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->name, ENT_QUOTES, 'UTF-8', true);
                    }
                    ?>
" alt="<?php 
                    if (!empty($_smarty_tpl->tpl_vars['cover']->value['legend'])) {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['cover']->value['legend'], ENT_QUOTES, 'UTF-8', true);
                    } else {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->name, ENT_QUOTES, 'UTF-8', true);
                    }
                    ?>
"/>
							</a>
						<?php 
                } else {
                    ?>
							<img id="bigpic" itemprop="image" src="<?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value->link_rewrite, $_smarty_tpl->tpl_vars['cover']->value['id_image'], 'large_default'), ENT_QUOTES, 'UTF-8', true);
                    ?>
" title="<?php 
                    if (!empty($_smarty_tpl->tpl_vars['cover']->value['legend'])) {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['cover']->value['legend'], ENT_QUOTES, 'UTF-8', true);
                    } else {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->name, ENT_QUOTES, 'UTF-8', true);
                    }
                    ?>
" alt="<?php 
                    if (!empty($_smarty_tpl->tpl_vars['cover']->value['legend'])) {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['cover']->value['legend'], ENT_QUOTES, 'UTF-8', true);
                    } else {
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->name, ENT_QUOTES, 'UTF-8', true);
                    }
                    ?>
" width="<?php 
                    echo $_smarty_tpl->tpl_vars['largeSize']->value['width'];
                    ?>
" height="<?php 
                    echo $_smarty_tpl->tpl_vars['largeSize']->value['height'];
                    ?>
"/>
							<?php 
                    if (!$_smarty_tpl->tpl_vars['content_only']->value) {
                        ?>
								<span class="span_link no-print"><?php 
                        echo smartyTranslate(array('s' => 'View larger'), $_smarty_tpl);
                        ?>
</span>
							<?php 
                    }
                    ?>
						<?php 
                }
                ?>
					</span>
				<?php 
            } else {
                ?>
					<span id="view_full_size">
						<img itemprop="image" src="<?php 
                echo $_smarty_tpl->tpl_vars['img_prod_dir']->value;
                echo $_smarty_tpl->tpl_vars['lang_iso']->value;
                ?>
-default-large_default.jpg" id="bigpic" alt="" title="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->name, ENT_QUOTES, 'UTF-8', true);
                ?>
" width="<?php 
                echo $_smarty_tpl->tpl_vars['largeSize']->value['width'];
                ?>
" height="<?php 
                echo $_smarty_tpl->tpl_vars['largeSize']->value['height'];
                ?>
"/>
						<?php 
                if (!$_smarty_tpl->tpl_vars['content_only']->value) {
                    ?>
							<span class="span_link">
								<?php 
                    echo smartyTranslate(array('s' => 'View larger'), $_smarty_tpl);
                    ?>

							</span>
						<?php 
                }
                ?>
					</span>
				<?php 
            }
            ?>
			</div> <!-- end image-block -->
			<?php 
            if (isset($_smarty_tpl->tpl_vars['images']->value) && count($_smarty_tpl->tpl_vars['images']->value) > 0) {
                ?>
				<!-- thumbnails -->
				<div id="views_block" class="clearfix <?php 
                if (isset($_smarty_tpl->tpl_vars['images']->value) && count($_smarty_tpl->tpl_vars['images']->value) < 2) {
                    ?>
hidden<?php 
                }
                ?>
">
					<?php 
                if (isset($_smarty_tpl->tpl_vars['images']->value) && count($_smarty_tpl->tpl_vars['images']->value) > 2) {
                    ?>
						<span class="view_scroll_spacer">
							<a id="view_scroll_left" class="" title="<?php 
                    echo smartyTranslate(array('s' => 'Other views'), $_smarty_tpl);
                    ?>
" href="javascript:{}">
								<?php 
                    echo smartyTranslate(array('s' => 'Previous'), $_smarty_tpl);
                    ?>

							</a>
						</span>
					<?php 
                }
                ?>
					<div id="thumbs_list">
						<ul id="thumbs_list_frame">
						<?php 
                if (isset($_smarty_tpl->tpl_vars['images']->value)) {
                    ?>
							<?php 
                    $_smarty_tpl->tpl_vars['image'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['image']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['images']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    $_smarty_tpl->tpl_vars['image']->total = $_smarty_tpl->_count($_from);
                    $_smarty_tpl->tpl_vars['image']->iteration = 0;
                    foreach ($_from as $_smarty_tpl->tpl_vars['image']->key => $_smarty_tpl->tpl_vars['image']->value) {
                        $_smarty_tpl->tpl_vars['image']->_loop = true;
                        $_smarty_tpl->tpl_vars['image']->iteration++;
                        $_smarty_tpl->tpl_vars['image']->last = $_smarty_tpl->tpl_vars['image']->iteration === $_smarty_tpl->tpl_vars['image']->total;
                        $_smarty_tpl->tpl_vars['smarty']->value['foreach']['thumbnails']['last'] = $_smarty_tpl->tpl_vars['image']->last;
                        ?>
								<?php 
                        $_smarty_tpl->tpl_vars['imageIds'] = new Smarty_variable((string) $_smarty_tpl->tpl_vars['product']->value->id . "-" . (string) $_smarty_tpl->tpl_vars['image']->value['id_image'], null, 0);
                        ?>
								<?php 
                        if (!empty($_smarty_tpl->tpl_vars['image']->value['legend'])) {
                            ?>
									<?php 
                            $_smarty_tpl->tpl_vars['imageTitle'] = new Smarty_variable(htmlspecialchars($_smarty_tpl->tpl_vars['image']->value['legend'], ENT_QUOTES, 'UTF-8', true), null, 0);
                            ?>
								<?php 
                        } else {
                            ?>
									<?php 
                            $_smarty_tpl->tpl_vars['imageTitle'] = new Smarty_variable(htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->name, ENT_QUOTES, 'UTF-8', true), null, 0);
                            ?>
								<?php 
                        }
                        ?>
								<li id="thumbnail_<?php 
                        echo $_smarty_tpl->tpl_vars['image']->value['id_image'];
                        ?>
"<?php 
                        if ($_smarty_tpl->getVariable('smarty')->value['foreach']['thumbnails']['last']) {
                            ?>
 class="last"<?php 
                        }
                        ?>
>
									<a<?php 
                        if ($_smarty_tpl->tpl_vars['jqZoomEnabled']->value && $_smarty_tpl->tpl_vars['have_image']->value && !$_smarty_tpl->tpl_vars['content_only']->value) {
                            ?>
 href="javascript:void(0);" rel="{gallery: 'gal1', smallimage: '<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value->link_rewrite, $_smarty_tpl->tpl_vars['imageIds']->value, 'large_default'), ENT_QUOTES, 'UTF-8', true);
                            ?>
',largeimage: '<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value->link_rewrite, $_smarty_tpl->tpl_vars['imageIds']->value, 'thickbox_default'), ENT_QUOTES, 'UTF-8', true);
                            ?>
'}"<?php 
                        } else {
                            ?>
 href="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value->link_rewrite, $_smarty_tpl->tpl_vars['imageIds']->value, 'thickbox_default'), ENT_QUOTES, 'UTF-8', true);
                            ?>
"	data-fancybox-group="other-views" class="fancybox<?php 
                            if ($_smarty_tpl->tpl_vars['image']->value['id_image'] == $_smarty_tpl->tpl_vars['cover']->value['id_image']) {
                                ?>
 shown<?php 
                            }
                            ?>
"<?php 
                        }
                        ?>
 title="<?php 
                        echo $_smarty_tpl->tpl_vars['imageTitle']->value;
                        ?>
">
										<img class="img-responsive" id="thumb_<?php 
                        echo $_smarty_tpl->tpl_vars['image']->value['id_image'];
                        ?>
" src="<?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['product']->value->link_rewrite, $_smarty_tpl->tpl_vars['imageIds']->value, 'cart_default'), ENT_QUOTES, 'UTF-8', true);
                        ?>
" alt="<?php 
                        echo $_smarty_tpl->tpl_vars['imageTitle']->value;
                        ?>
" title="<?php 
                        echo $_smarty_tpl->tpl_vars['imageTitle']->value;
                        ?>
"<?php 
                        if (isset($_smarty_tpl->tpl_vars['cartSize']->value)) {
                            ?>
 height="<?php 
                            echo $_smarty_tpl->tpl_vars['cartSize']->value['height'];
                            ?>
" width="<?php 
                            echo $_smarty_tpl->tpl_vars['cartSize']->value['width'];
                            ?>
"<?php 
                        }
                        ?>
 itemprop="image" />
									</a>
								</li>
							<?php 
                    }
                    ?>
						<?php 
                }
                ?>
						</ul>
					</div> <!-- end thumbs_list -->
					<?php 
                if (isset($_smarty_tpl->tpl_vars['images']->value) && count($_smarty_tpl->tpl_vars['images']->value) > 2) {
                    ?>
						<a id="view_scroll_right" title="<?php 
                    echo smartyTranslate(array('s' => 'Other views'), $_smarty_tpl);
                    ?>
" href="javascript:{}">
							<?php 
                    echo smartyTranslate(array('s' => 'Next'), $_smarty_tpl);
                    ?>

						</a>
					<?php 
                }
                ?>
				</div> <!-- end views-block -->
				<!-- end thumbnails -->
			<?php 
            }
            ?>
			<?php 
            if (isset($_smarty_tpl->tpl_vars['images']->value) && count($_smarty_tpl->tpl_vars['images']->value) > 1) {
                ?>
				<p class="resetimg clear no-print">
					<span id="wrapResetImages" style="display: none;">
						<a href="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getProductLink($_smarty_tpl->tpl_vars['product']->value), ENT_QUOTES, 'UTF-8', true);
                ?>
" data-id="resetImages">
							<i class="icon-repeat"></i>
							<?php 
                echo smartyTranslate(array('s' => 'Display all pictures'), $_smarty_tpl);
                ?>

						</a>
					</span>
				</p>
			<?php 
            }
            ?>
		</div> <!-- end pb-left-column -->
		<!-- end left infos-->
		<!-- center infos -->
		<div class="pb-center-column col-xs-12 col-sm-6">
					<div class="wishlist_box"><?php 
            if (isset($_smarty_tpl->tpl_vars['HOOK_PRODUCT_ACTIONS']->value) && $_smarty_tpl->tpl_vars['HOOK_PRODUCT_ACTIONS']->value) {
                echo $_smarty_tpl->tpl_vars['HOOK_PRODUCT_ACTIONS']->value;
            }
            ?>
</div>
			<?php 
            if ($_smarty_tpl->tpl_vars['product']->value->online_only) {
                ?>
				<p class="online_only"><?php 
                echo smartyTranslate(array('s' => 'Online only'), $_smarty_tpl);
                ?>
</p>
			<?php 
            }
            ?>
			<h1 itemprop="name"><?php 
            echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->name, ENT_QUOTES, 'UTF-8', true);
            ?>
</h1>
			<p id="product_reference"<?php 
            if (empty($_smarty_tpl->tpl_vars['product']->value->reference) || !$_smarty_tpl->tpl_vars['product']->value->reference) {
                ?>
 style="display: none;"<?php 
            }
            ?>
>
				<label><?php 
            echo smartyTranslate(array('s' => 'Reference:'), $_smarty_tpl);
            ?>
 </label>
				<span class="editable" itemprop="sku"<?php 
            if (!empty($_smarty_tpl->tpl_vars['product']->value->reference) && $_smarty_tpl->tpl_vars['product']->value->reference) {
                ?>
 content="<?php 
                echo $_smarty_tpl->tpl_vars['product']->value->reference;
                ?>
"<?php 
            }
            ?>
><?php 
            if (!isset($_smarty_tpl->tpl_vars['groups']->value)) {
                echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->reference, ENT_QUOTES, 'UTF-8', true);
            }
            ?>
</span>
			</p>
			<?php 
            if (!$_smarty_tpl->tpl_vars['product']->value->is_virtual && $_smarty_tpl->tpl_vars['product']->value->condition) {
                ?>
			<p id="product_condition">
				<label><?php 
                echo smartyTranslate(array('s' => 'Condition:'), $_smarty_tpl);
                ?>
 </label>
				<?php 
                if ($_smarty_tpl->tpl_vars['product']->value->condition == 'new') {
                    ?>
					<link itemprop="itemCondition" href="https://schema.org/NewCondition"/>
					<span class="editable"><?php 
                    echo smartyTranslate(array('s' => 'New product'), $_smarty_tpl);
                    ?>
</span>
				<?php 
                } elseif ($_smarty_tpl->tpl_vars['product']->value->condition == 'used') {
                    ?>
					<link itemprop="itemCondition" href="https://schema.org/UsedCondition"/>
					<span class="editable"><?php 
                    echo smartyTranslate(array('s' => 'Used'), $_smarty_tpl);
                    ?>
</span>
				<?php 
                } elseif ($_smarty_tpl->tpl_vars['product']->value->condition == 'refurbished') {
                    ?>
					<link itemprop="itemCondition" href="https://schema.org/RefurbishedCondition"/>
					<span class="editable"><?php 
                    echo smartyTranslate(array('s' => 'Refurbished'), $_smarty_tpl);
                    ?>
</span>
				<?php 
                }
                ?>
			</p>
			<?php 
            }
            ?>
			<?php 
            if ($_smarty_tpl->tpl_vars['product']->value->description_short || count($_smarty_tpl->tpl_vars['packItems']->value) > 0) {
                ?>
				<div id="short_description_block">
					<?php 
                if ($_smarty_tpl->tpl_vars['product']->value->description_short) {
                    ?>
						<div id="short_description_content" class="rte align_justify" itemprop="description"><?php 
                    echo $_smarty_tpl->tpl_vars['product']->value->description_short;
                    ?>
</div>
					<?php 
                }
                ?>

					<?php 
                if ($_smarty_tpl->tpl_vars['product']->value->description) {
                    ?>
						<p class="buttons_bottom_block">
							<a href="javascript:{}" class="button">
								<?php 
                    echo smartyTranslate(array('s' => 'More details'), $_smarty_tpl);
                    ?>

							</a>
						</p>
					<?php 
                }
                ?>
					<!--<?php 
                if (count($_smarty_tpl->tpl_vars['packItems']->value) > 0) {
                    ?>
						<div class="short_description_pack">
						<h3><?php 
                    echo smartyTranslate(array('s' => 'Pack content'), $_smarty_tpl);
                    ?>
</h3>
							<?php 
                    $_smarty_tpl->tpl_vars['packItem'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['packItem']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['packItems']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['packItem']->key => $_smarty_tpl->tpl_vars['packItem']->value) {
                        $_smarty_tpl->tpl_vars['packItem']->_loop = true;
                        ?>

							<div class="pack_content">
								<?php 
                        echo $_smarty_tpl->tpl_vars['packItem']->value['pack_quantity'];
                        ?>
 x <a href="<?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getProductLink($_smarty_tpl->tpl_vars['packItem']->value['id_product'], $_smarty_tpl->tpl_vars['packItem']->value['link_rewrite'], $_smarty_tpl->tpl_vars['packItem']->value['category']), ENT_QUOTES, 'UTF-8', true);
                        ?>
"><?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['packItem']->value['name'], ENT_QUOTES, 'UTF-8', true);
                        ?>
</a>
								<p><?php 
                        echo $_smarty_tpl->tpl_vars['packItem']->value['description_short'];
                        ?>
</p>
							</div>
							<?php 
                    }
                    ?>
						</div>
					<?php 
                }
                ?>
-->
				</div> <!-- end short_description_block -->
			<?php 
            }
            ?>
			<?php 
            if ($_smarty_tpl->tpl_vars['display_qties']->value == 1 && !$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value && $_smarty_tpl->tpl_vars['PS_STOCK_MANAGEMENT']->value && $_smarty_tpl->tpl_vars['product']->value->available_for_order) {
                ?>
				<!-- number of item in stock -->
				<p id="pQuantityAvailable"<?php 
                if ($_smarty_tpl->tpl_vars['product']->value->quantity <= 0) {
                    ?>
 style="display: none;"<?php 
                }
                ?>
>
					<span id="quantityAvailable"><?php 
                echo intval($_smarty_tpl->tpl_vars['product']->value->quantity);
                ?>
</span>
					<span <?php 
                if ($_smarty_tpl->tpl_vars['product']->value->quantity > 1) {
                    ?>
 style="display: none;"<?php 
                }
                ?>
 id="quantityAvailableTxt"><?php 
                echo smartyTranslate(array('s' => 'Item'), $_smarty_tpl);
                ?>
</span>
					<span <?php 
                if ($_smarty_tpl->tpl_vars['product']->value->quantity == 1) {
                    ?>
 style="display: none;"<?php 
                }
                ?>
 id="quantityAvailableTxtMultiple"><?php 
                echo smartyTranslate(array('s' => 'Items'), $_smarty_tpl);
                ?>
</span>
				</p>
			<?php 
            }
            ?>
			<!-- availability or doesntExist -->
			<p id="availability_statut"<?php 
            if (!$_smarty_tpl->tpl_vars['PS_STOCK_MANAGEMENT']->value || $_smarty_tpl->tpl_vars['product']->value->quantity <= 0 && !$_smarty_tpl->tpl_vars['product']->value->available_later && $_smarty_tpl->tpl_vars['allow_oosp']->value || $_smarty_tpl->tpl_vars['product']->value->quantity > 0 && !$_smarty_tpl->tpl_vars['product']->value->available_now || !$_smarty_tpl->tpl_vars['product']->value->available_for_order || $_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) {
                ?>
 style="display: none;"<?php 
            }
            ?>
>
				
				<span id="availability_value" class="label<?php 
            if ($_smarty_tpl->tpl_vars['product']->value->quantity <= 0 && !$_smarty_tpl->tpl_vars['allow_oosp']->value) {
                ?>
 label-danger<?php 
            } elseif ($_smarty_tpl->tpl_vars['product']->value->quantity <= 0) {
                ?>
 label-warning<?php 
            } else {
                ?>
 label-success<?php 
            }
            ?>
"><?php 
            if ($_smarty_tpl->tpl_vars['product']->value->quantity <= 0) {
                if ($_smarty_tpl->tpl_vars['PS_STOCK_MANAGEMENT']->value && $_smarty_tpl->tpl_vars['allow_oosp']->value) {
                    echo $_smarty_tpl->tpl_vars['product']->value->available_later;
                } else {
                    echo smartyTranslate(array('s' => 'This product is no longer in stock'), $_smarty_tpl);
                }
            } elseif ($_smarty_tpl->tpl_vars['PS_STOCK_MANAGEMENT']->value) {
                echo $_smarty_tpl->tpl_vars['product']->value->available_now;
            }
            ?>
</span>
			</p>
			<?php 
            if ($_smarty_tpl->tpl_vars['PS_STOCK_MANAGEMENT']->value) {
                ?>
				<?php 
                if (!$_smarty_tpl->tpl_vars['product']->value->is_virtual) {
                    echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductDeliveryTime", 'product' => $_smarty_tpl->tpl_vars['product']->value), $_smarty_tpl);
                }
                ?>
				<p class="warning_inline" id="last_quantities"<?php 
                if ($_smarty_tpl->tpl_vars['product']->value->quantity > $_smarty_tpl->tpl_vars['last_qties']->value || $_smarty_tpl->tpl_vars['product']->value->quantity <= 0 || $_smarty_tpl->tpl_vars['allow_oosp']->value || !$_smarty_tpl->tpl_vars['product']->value->available_for_order || $_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) {
                    ?>
 style="display: none"<?php 
                }
                ?>
 ><?php 
                echo smartyTranslate(array('s' => 'Warning: Last items in stock!'), $_smarty_tpl);
                ?>
</p>
			<?php 
            }
            ?>
			<p id="availability_date"<?php 
            if ($_smarty_tpl->tpl_vars['product']->value->quantity > 0 || !$_smarty_tpl->tpl_vars['product']->value->available_for_order || $_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value || !isset($_smarty_tpl->tpl_vars['product']->value->available_date) || $_smarty_tpl->tpl_vars['product']->value->available_date < smarty_modifier_date_format(time(), '%Y-%m-%d')) {
                ?>
 style="display: none;"<?php 
            }
            ?>
>
				<span id="availability_date_label"><?php 
            echo smartyTranslate(array('s' => 'Availability date:'), $_smarty_tpl);
            ?>
</span>
				<span id="availability_date_value"><?php 
            if (Validate::isDate($_smarty_tpl->tpl_vars['product']->value->available_date)) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['dateFormat'][0][0]->dateFormat(array('date' => $_smarty_tpl->tpl_vars['product']->value->available_date, 'full' => false), $_smarty_tpl);
            }
            ?>
</span>
			</p>
			<!-- Out of stock hook -->
			<div id="oosHook"<?php 
            if ($_smarty_tpl->tpl_vars['product']->value->quantity > 0) {
                ?>
 style="display: none;"<?php 
            }
            ?>
>
				<?php 
            echo $_smarty_tpl->tpl_vars['HOOK_PRODUCT_OOS']->value;
            ?>

			</div>
			<?php 
            if (isset($_smarty_tpl->tpl_vars['HOOK_EXTRA_RIGHT']->value) && $_smarty_tpl->tpl_vars['HOOK_EXTRA_RIGHT']->value) {
                echo $_smarty_tpl->tpl_vars['HOOK_EXTRA_RIGHT']->value;
            }
            ?>
			<?php 
            if (!$_smarty_tpl->tpl_vars['content_only']->value) {
                ?>
				<!-- usefull links-->
				<ul id="usefull_link_block" class="clearfix no-print">
					<?php 
                if ($_smarty_tpl->tpl_vars['HOOK_EXTRA_LEFT']->value) {
                    echo $_smarty_tpl->tpl_vars['HOOK_EXTRA_LEFT']->value;
                }
                ?>
					<li class="print">
						<a href="javascript:print();">
							<?php 
                echo smartyTranslate(array('s' => 'Print'), $_smarty_tpl);
                ?>

						</a>
					</li>
				</ul>
			<?php 
            }
            ?>
	<div class="pb-right-column col-xs-12 p0">
			<?php 
            if ($_smarty_tpl->tpl_vars['product']->value->show_price && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value) || isset($_smarty_tpl->tpl_vars['groups']->value) || $_smarty_tpl->tpl_vars['product']->value->reference || isset($_smarty_tpl->tpl_vars['HOOK_PRODUCT_ACTIONS']->value) && $_smarty_tpl->tpl_vars['HOOK_PRODUCT_ACTIONS']->value) {
                ?>
			<!-- add to cart form-->
			<form id="buy_block"<?php 
                if ($_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value && !isset($_smarty_tpl->tpl_vars['groups']->value) && $_smarty_tpl->tpl_vars['product']->value->quantity > 0) {
                    ?>
 class="hidden"<?php 
                }
                ?>
 action="<?php 
                echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('cart'), ENT_QUOTES, 'UTF-8', true);
                ?>
" method="post">
				<!-- hidden datas -->
				<p class="hidden">
					<input type="hidden" name="token" value="<?php 
                echo $_smarty_tpl->tpl_vars['static_token']->value;
                ?>
" />
					<input type="hidden" name="id_product" value="<?php 
                echo intval($_smarty_tpl->tpl_vars['product']->value->id);
                ?>
" id="product_page_product_id" />
					<input type="hidden" name="add" value="1" />
					<input type="hidden" name="id_product_attribute" id="idCombination" value="" />
				</p>
				<div class="box-info-product">
					<div class="content_prices clearfix">
						<?php 
                if ($_smarty_tpl->tpl_vars['product']->value->show_price && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value) && !$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) {
                    ?>
							<!-- prices -->
							<div>
								<p class="our_price_display" itemprop="offers" itemscope itemtype="https://schema.org/Offer"><?php 
                    if ($_smarty_tpl->tpl_vars['product']->value->quantity > 0) {
                        ?>
<link itemprop="availability" href="https://schema.org/InStock"/><?php 
                    }
                    if ($_smarty_tpl->tpl_vars['priceDisplay']->value >= 0 && $_smarty_tpl->tpl_vars['priceDisplay']->value <= 2) {
                        ?>
<span id="our_price_display" class="price" itemprop="price" content="<?php 
                        echo $_smarty_tpl->tpl_vars['productPrice']->value;
                        ?>
"><?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => floatval($_smarty_tpl->tpl_vars['productPrice']->value)), $_smarty_tpl);
                        ?>
</span><?php 
                        if ($_smarty_tpl->tpl_vars['tax_enabled']->value && (isset($_smarty_tpl->tpl_vars['display_tax_label']->value) && $_smarty_tpl->tpl_vars['display_tax_label']->value == 1 || !isset($_smarty_tpl->tpl_vars['display_tax_label']->value))) {
                            if ($_smarty_tpl->tpl_vars['priceDisplay']->value == 1) {
                                ?>
 <?php 
                                echo smartyTranslate(array('s' => 'tax excl.'), $_smarty_tpl);
                            } else {
                                ?>
 <?php 
                                echo smartyTranslate(array('s' => 'tax incl.'), $_smarty_tpl);
                            }
                        }
                        ?>
<meta itemprop="priceCurrency" content="<?php 
                        echo $_smarty_tpl->tpl_vars['currency']->value->iso_code;
                        ?>
" /><?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "price"), $_smarty_tpl);
                    }
                    ?>
</p>
								<p id="reduction_percent" <?php 
                    if (!$_smarty_tpl->tpl_vars['product']->value->specificPrice || $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction_type'] != 'percentage') {
                        ?>
 style="display:none;"<?php 
                    }
                    ?>
><span id="reduction_percent_display"><?php 
                    if ($_smarty_tpl->tpl_vars['product']->value->specificPrice && $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction_type'] == 'percentage') {
                        ?>
-<?php 
                        echo $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction'] * 100;
                        ?>
%<?php 
                    }
                    ?>
</span></p>
								<p id="reduction_amount" <?php 
                    if (!$_smarty_tpl->tpl_vars['product']->value->specificPrice || $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction_type'] != 'amount' || floatval($_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction']) == 0) {
                        ?>
 style="display:none"<?php 
                    }
                    ?>
><span id="reduction_amount_display"><?php 
                    if ($_smarty_tpl->tpl_vars['product']->value->specificPrice && $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction_type'] == 'amount' && floatval($_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction']) != 0) {
                        ?>
-<?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value) - floatval($_smarty_tpl->tpl_vars['productPrice']->value)), $_smarty_tpl);
                    }
                    ?>
</span></p>
								<p id="old_price"<?php 
                    if (!$_smarty_tpl->tpl_vars['product']->value->specificPrice || !$_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction']) {
                        ?>
 class="hidden"<?php 
                    }
                    ?>
><?php 
                    if ($_smarty_tpl->tpl_vars['priceDisplay']->value >= 0 && $_smarty_tpl->tpl_vars['priceDisplay']->value <= 2) {
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "old_price"), $_smarty_tpl);
                        ?>
<span id="old_price_display"><span class="price"><?php 
                        if ($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value > $_smarty_tpl->tpl_vars['productPrice']->value) {
                            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value)), $_smarty_tpl);
                        }
                        ?>
</span><?php 
                        if ($_smarty_tpl->tpl_vars['tax_enabled']->value && $_smarty_tpl->tpl_vars['display_tax_label']->value == 1) {
                            ?>
 <?php 
                            if ($_smarty_tpl->tpl_vars['priceDisplay']->value == 1) {
                                echo smartyTranslate(array('s' => 'tax excl.'), $_smarty_tpl);
                            } else {
                                echo smartyTranslate(array('s' => 'tax incl.'), $_smarty_tpl);
                            }
                        }
                        ?>
</span><?php 
                    }
                    ?>
</p>
								<?php 
                    if ($_smarty_tpl->tpl_vars['priceDisplay']->value == 2) {
                        ?>
									<br />
									<span id="pretaxe_price"><span id="pretaxe_price_display"><?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value->getPrice(false, @constant('NULL'))), $_smarty_tpl);
                        ?>
</span> <?php 
                        echo smartyTranslate(array('s' => 'tax excl.'), $_smarty_tpl);
                        ?>
</span>
								<?php 
                    }
                    ?>
							</div> <!-- end prices -->
							<?php 
                    if (count($_smarty_tpl->tpl_vars['packItems']->value) && $_smarty_tpl->tpl_vars['productPrice']->value < $_smarty_tpl->tpl_vars['product']->value->getNoPackPrice()) {
                        ?>
								<p class="pack_price"><?php 
                        echo smartyTranslate(array('s' => 'Instead of'), $_smarty_tpl);
                        ?>
 <span style="text-decoration: line-through;"><?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['product']->value->getNoPackPrice()), $_smarty_tpl);
                        ?>
</span></p>
							<?php 
                    }
                    ?>
							<?php 
                    if ($_smarty_tpl->tpl_vars['product']->value->ecotax != 0) {
                        ?>
								<p class="price-ecotax"><?php 
                        echo smartyTranslate(array('s' => 'Including'), $_smarty_tpl);
                        ?>
 <span id="ecotax_price_display"><?php 
                        if ($_smarty_tpl->tpl_vars['priceDisplay']->value == 2) {
                            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['convertAndFormatPrice'][0][0]->convertAndFormatPrice($_smarty_tpl->tpl_vars['ecotax_tax_exc']->value);
                        } else {
                            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['convertAndFormatPrice'][0][0]->convertAndFormatPrice($_smarty_tpl->tpl_vars['ecotax_tax_inc']->value);
                        }
                        ?>
</span> <?php 
                        echo smartyTranslate(array('s' => 'for ecotax'), $_smarty_tpl);
                        ?>

									<?php 
                        if ($_smarty_tpl->tpl_vars['product']->value->specificPrice && $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction']) {
                            ?>
									<br /><?php 
                            echo smartyTranslate(array('s' => '(not impacted by the discount)'), $_smarty_tpl);
                            ?>

									<?php 
                        }
                        ?>
								</p>
							<?php 
                    }
                    ?>
							<?php 
                    if (!empty($_smarty_tpl->tpl_vars['product']->value->unity) && $_smarty_tpl->tpl_vars['product']->value->unit_price_ratio > 0.0) {
                        ?>
								<?php 
                        echo smarty_function_math(array('equation' => "pprice / punit_price", 'pprice' => $_smarty_tpl->tpl_vars['productPrice']->value, 'punit_price' => $_smarty_tpl->tpl_vars['product']->value->unit_price_ratio, 'assign' => 'unit_price'), $_smarty_tpl);
                        ?>

								<p class="unit-price"><span id="unit_price_display"><?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['unit_price']->value), $_smarty_tpl);
                        ?>
</span> <?php 
                        echo smartyTranslate(array('s' => 'per'), $_smarty_tpl);
                        ?>
 <?php 
                        echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->unity, ENT_QUOTES, 'UTF-8', true);
                        ?>
</p>
								<?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "unit_price"), $_smarty_tpl);
                        ?>

							<?php 
                    }
                    ?>
						<?php 
                }
                ?>
 
						<?php 
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "weight", 'hook_origin' => 'product_sheet'), $_smarty_tpl);
                ?>

                        <?php 
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['hook'][0][0]->smartyHook(array('h' => "displayProductPriceBlock", 'product' => $_smarty_tpl->tpl_vars['product']->value, 'type' => "after_price"), $_smarty_tpl);
                ?>

						<div class="clear"></div>
					</div> <!-- end content_prices -->
					<div class="product_attributes clearfix">
						<!-- quantity wanted -->
						<?php 
                if (!$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) {
                    ?>
						<p id="quantity_wanted_p"<?php 
                    if (!$_smarty_tpl->tpl_vars['allow_oosp']->value && $_smarty_tpl->tpl_vars['product']->value->quantity <= 0 || !$_smarty_tpl->tpl_vars['product']->value->available_for_order || $_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) {
                        ?>
 style="display: none;"<?php 
                    }
                    ?>
>
							<label for="quantity_wanted"><?php 
                    echo smartyTranslate(array('s' => 'Quantity'), $_smarty_tpl);
                    ?>
</label>
							<input type="number" min="1" name="qty" id="quantity_wanted" class="text" value="<?php 
                    if (isset($_smarty_tpl->tpl_vars['quantityBackup']->value)) {
                        echo intval($_smarty_tpl->tpl_vars['quantityBackup']->value);
                    } else {
                        if ($_smarty_tpl->tpl_vars['product']->value->minimal_quantity > 1) {
                            echo $_smarty_tpl->tpl_vars['product']->value->minimal_quantity;
                        } else {
                            ?>
1<?php 
                        }
                    }
                    ?>
" />
							<a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down">
								<span><i class="icon-minus"></i></span>
							</a>
							<a href="#" data-field-qty="qty" class="btn btn-default button-plus product_quantity_up">
								<span><i class="icon-plus"></i></span>
							</a>
							<span class="clearfix"></span>
						</p>
						<?php 
                }
                ?>
						<!-- minimal quantity wanted -->
						<p id="minimal_quantity_wanted_p"<?php 
                if ($_smarty_tpl->tpl_vars['product']->value->minimal_quantity <= 1 || !$_smarty_tpl->tpl_vars['product']->value->available_for_order || $_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) {
                    ?>
 style="display: none;"<?php 
                }
                ?>
>
							<?php 
                echo smartyTranslate(array('s' => 'The minimum purchase order quantity for the product is'), $_smarty_tpl);
                ?>
 <b id="minimal_quantity_label"><?php 
                echo $_smarty_tpl->tpl_vars['product']->value->minimal_quantity;
                ?>
</b>
						</p>
						<?php 
                if (isset($_smarty_tpl->tpl_vars['groups']->value)) {
                    ?>
							<!-- attributes -->
							<div id="attributes">
								<div class="clearfix"></div>
								<?php 
                    $_smarty_tpl->tpl_vars['group'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['group']->_loop = false;
                    $_smarty_tpl->tpl_vars['id_attribute_group'] = new Smarty_Variable();
                    $_from = $_smarty_tpl->tpl_vars['groups']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['group']->key => $_smarty_tpl->tpl_vars['group']->value) {
                        $_smarty_tpl->tpl_vars['group']->_loop = true;
                        $_smarty_tpl->tpl_vars['id_attribute_group']->value = $_smarty_tpl->tpl_vars['group']->key;
                        ?>
									<?php 
                        if (count($_smarty_tpl->tpl_vars['group']->value['attributes'])) {
                            ?>
										<fieldset class="attribute_fieldset">
											<label class="attribute_label" <?php 
                            if ($_smarty_tpl->tpl_vars['group']->value['group_type'] != 'color' && $_smarty_tpl->tpl_vars['group']->value['group_type'] != 'radio') {
                                ?>
for="group_<?php 
                                echo intval($_smarty_tpl->tpl_vars['id_attribute_group']->value);
                                ?>
"<?php 
                            }
                            ?>
><?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['group']->value['name'], ENT_QUOTES, 'UTF-8', true);
                            ?>
&nbsp;</label>
											<?php 
                            $_smarty_tpl->tpl_vars["groupName"] = new Smarty_variable("group_" . (string) $_smarty_tpl->tpl_vars['id_attribute_group']->value, null, 0);
                            ?>
											<div class="attribute_list">
												<?php 
                            if ($_smarty_tpl->tpl_vars['group']->value['group_type'] == 'select') {
                                ?>
													<select name="<?php 
                                echo $_smarty_tpl->tpl_vars['groupName']->value;
                                ?>
" id="group_<?php 
                                echo intval($_smarty_tpl->tpl_vars['id_attribute_group']->value);
                                ?>
" class="form-control attribute_select no-print">
														<?php 
                                $_smarty_tpl->tpl_vars['group_attribute'] = new Smarty_Variable();
                                $_smarty_tpl->tpl_vars['group_attribute']->_loop = false;
                                $_smarty_tpl->tpl_vars['id_attribute'] = new Smarty_Variable();
                                $_from = $_smarty_tpl->tpl_vars['group']->value['attributes'];
                                if (!is_array($_from) && !is_object($_from)) {
                                    settype($_from, 'array');
                                }
                                foreach ($_from as $_smarty_tpl->tpl_vars['group_attribute']->key => $_smarty_tpl->tpl_vars['group_attribute']->value) {
                                    $_smarty_tpl->tpl_vars['group_attribute']->_loop = true;
                                    $_smarty_tpl->tpl_vars['id_attribute']->value = $_smarty_tpl->tpl_vars['group_attribute']->key;
                                    ?>
															<option value="<?php 
                                    echo intval($_smarty_tpl->tpl_vars['id_attribute']->value);
                                    ?>
"<?php 
                                    if (isset($_GET[$_smarty_tpl->tpl_vars['groupName']->value]) && intval($_GET[$_smarty_tpl->tpl_vars['groupName']->value]) == $_smarty_tpl->tpl_vars['id_attribute']->value || $_smarty_tpl->tpl_vars['group']->value['default'] == $_smarty_tpl->tpl_vars['id_attribute']->value) {
                                        ?>
 selected="selected"<?php 
                                    }
                                    ?>
 title="<?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['group_attribute']->value, ENT_QUOTES, 'UTF-8', true);
                                    ?>
"><?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['group_attribute']->value, ENT_QUOTES, 'UTF-8', true);
                                    ?>
</option>
														<?php 
                                }
                                ?>
													</select>
												<?php 
                            } elseif ($_smarty_tpl->tpl_vars['group']->value['group_type'] == 'color') {
                                ?>
													<ul id="color_to_pick_list" class="clearfix">
														<?php 
                                $_smarty_tpl->tpl_vars["default_colorpicker"] = new Smarty_variable('', null, 0);
                                ?>
														<?php 
                                $_smarty_tpl->tpl_vars['group_attribute'] = new Smarty_Variable();
                                $_smarty_tpl->tpl_vars['group_attribute']->_loop = false;
                                $_smarty_tpl->tpl_vars['id_attribute'] = new Smarty_Variable();
                                $_from = $_smarty_tpl->tpl_vars['group']->value['attributes'];
                                if (!is_array($_from) && !is_object($_from)) {
                                    settype($_from, 'array');
                                }
                                foreach ($_from as $_smarty_tpl->tpl_vars['group_attribute']->key => $_smarty_tpl->tpl_vars['group_attribute']->value) {
                                    $_smarty_tpl->tpl_vars['group_attribute']->_loop = true;
                                    $_smarty_tpl->tpl_vars['id_attribute']->value = $_smarty_tpl->tpl_vars['group_attribute']->key;
                                    ?>
															<?php 
                                    $_smarty_tpl->tpl_vars['img_color_exists'] = new Smarty_variable(file_exists($_smarty_tpl->tpl_vars['col_img_dir']->value . $_smarty_tpl->tpl_vars['id_attribute']->value . '.jpg'), null, 0);
                                    ?>
															<li<?php 
                                    if ($_smarty_tpl->tpl_vars['group']->value['default'] == $_smarty_tpl->tpl_vars['id_attribute']->value) {
                                        ?>
 class="selected"<?php 
                                    }
                                    ?>
>
																<a href="<?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getProductLink($_smarty_tpl->tpl_vars['product']->value), ENT_QUOTES, 'UTF-8', true);
                                    ?>
" id="color_<?php 
                                    echo intval($_smarty_tpl->tpl_vars['id_attribute']->value);
                                    ?>
" name="<?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['colors']->value[$_smarty_tpl->tpl_vars['id_attribute']->value]['name'], ENT_QUOTES, 'UTF-8', true);
                                    ?>
" class="color_pick<?php 
                                    if ($_smarty_tpl->tpl_vars['group']->value['default'] == $_smarty_tpl->tpl_vars['id_attribute']->value) {
                                        ?>
 selected<?php 
                                    }
                                    ?>
"<?php 
                                    if (!$_smarty_tpl->tpl_vars['img_color_exists']->value && isset($_smarty_tpl->tpl_vars['colors']->value[$_smarty_tpl->tpl_vars['id_attribute']->value]['value']) && $_smarty_tpl->tpl_vars['colors']->value[$_smarty_tpl->tpl_vars['id_attribute']->value]['value']) {
                                        ?>
 style="background:<?php 
                                        echo htmlspecialchars($_smarty_tpl->tpl_vars['colors']->value[$_smarty_tpl->tpl_vars['id_attribute']->value]['value'], ENT_QUOTES, 'UTF-8', true);
                                        ?>
;"<?php 
                                    }
                                    ?>
 title="<?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['colors']->value[$_smarty_tpl->tpl_vars['id_attribute']->value]['name'], ENT_QUOTES, 'UTF-8', true);
                                    ?>
">
																	<?php 
                                    if ($_smarty_tpl->tpl_vars['img_color_exists']->value) {
                                        ?>
																		<img src="<?php 
                                        echo $_smarty_tpl->tpl_vars['img_col_dir']->value;
                                        echo intval($_smarty_tpl->tpl_vars['id_attribute']->value);
                                        ?>
.jpg" alt="<?php 
                                        echo htmlspecialchars($_smarty_tpl->tpl_vars['colors']->value[$_smarty_tpl->tpl_vars['id_attribute']->value]['name'], ENT_QUOTES, 'UTF-8', true);
                                        ?>
" title="<?php 
                                        echo htmlspecialchars($_smarty_tpl->tpl_vars['colors']->value[$_smarty_tpl->tpl_vars['id_attribute']->value]['name'], ENT_QUOTES, 'UTF-8', true);
                                        ?>
" width="20" height="20" />
																	<?php 
                                    }
                                    ?>
																</a>
															</li>
															<?php 
                                    if ($_smarty_tpl->tpl_vars['group']->value['default'] == $_smarty_tpl->tpl_vars['id_attribute']->value) {
                                        ?>
																<?php 
                                        $_smarty_tpl->tpl_vars['default_colorpicker'] = new Smarty_variable($_smarty_tpl->tpl_vars['id_attribute']->value, null, 0);
                                        ?>
															<?php 
                                    }
                                    ?>
														<?php 
                                }
                                ?>
													</ul>
													<input type="hidden" class="color_pick_hidden" name="<?php 
                                echo htmlspecialchars($_smarty_tpl->tpl_vars['groupName']->value, ENT_QUOTES, 'UTF-8', true);
                                ?>
" value="<?php 
                                echo intval($_smarty_tpl->tpl_vars['default_colorpicker']->value);
                                ?>
" />
												<?php 
                            } elseif ($_smarty_tpl->tpl_vars['group']->value['group_type'] == 'radio') {
                                ?>
													<ul>
														<?php 
                                $_smarty_tpl->tpl_vars['group_attribute'] = new Smarty_Variable();
                                $_smarty_tpl->tpl_vars['group_attribute']->_loop = false;
                                $_smarty_tpl->tpl_vars['id_attribute'] = new Smarty_Variable();
                                $_from = $_smarty_tpl->tpl_vars['group']->value['attributes'];
                                if (!is_array($_from) && !is_object($_from)) {
                                    settype($_from, 'array');
                                }
                                foreach ($_from as $_smarty_tpl->tpl_vars['group_attribute']->key => $_smarty_tpl->tpl_vars['group_attribute']->value) {
                                    $_smarty_tpl->tpl_vars['group_attribute']->_loop = true;
                                    $_smarty_tpl->tpl_vars['id_attribute']->value = $_smarty_tpl->tpl_vars['group_attribute']->key;
                                    ?>
															<li>
																<input type="radio" class="attribute_radio" name="<?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['groupName']->value, ENT_QUOTES, 'UTF-8', true);
                                    ?>
" value="<?php 
                                    echo $_smarty_tpl->tpl_vars['id_attribute']->value;
                                    ?>
" <?php 
                                    if ($_smarty_tpl->tpl_vars['group']->value['default'] == $_smarty_tpl->tpl_vars['id_attribute']->value) {
                                        ?>
 checked="checked"<?php 
                                    }
                                    ?>
 />
																<span><?php 
                                    echo htmlspecialchars($_smarty_tpl->tpl_vars['group_attribute']->value, ENT_QUOTES, 'UTF-8', true);
                                    ?>
</span>
															</li>
														<?php 
                                }
                                ?>
													</ul>
												<?php 
                            }
                            ?>
											</div> <!-- end attribute_list -->
										</fieldset>
									<?php 
                        }
                        ?>
								<?php 
                    }
                    ?>
							</div> <!-- end attributes -->
						<?php 
                }
                ?>
					</div> <!-- end product_attributes -->
					<div class="box-cart-bottom">
						<div<?php 
                if (!$_smarty_tpl->tpl_vars['allow_oosp']->value && $_smarty_tpl->tpl_vars['product']->value->quantity <= 0 || !$_smarty_tpl->tpl_vars['product']->value->available_for_order || isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value) && $_smarty_tpl->tpl_vars['restricted_country_mode']->value || $_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) {
                    ?>
 class="unvisible"<?php 
                }
                ?>
>
							<p id="add_to_cart" class="buttons_bottom_block no-print">
								<button type="submit" name="Submit" class="xiami">
									<span><?php 
                if ($_smarty_tpl->tpl_vars['content_only']->value && (isset($_smarty_tpl->tpl_vars['product']->value->customization_required) && $_smarty_tpl->tpl_vars['product']->value->customization_required)) {
                    echo smartyTranslate(array('s' => 'Customize'), $_smarty_tpl);
                } else {
                    echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl);
                }
                ?>
</span>
								</button>
							</p>
						</div>
					</div> <!-- end box-cart-bottom -->
				</div> <!-- end box-info-product -->
			</form>
			<?php 
            }
            ?>
		</div> <!-- end pb-right-column-->

		</div>
		<!-- end center infos-->
		<!-- pb-right-column-->

	

	<div class="producttags">
		<span class="tags">Tagi:</span>
    <?php 
            $_smarty_tpl->tpl_vars['v'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['v']->_loop = false;
            $_smarty_tpl->tpl_vars['k'] = new Smarty_Variable();
            $_from = Tag::getProductTags(Tools::getValue('id_product'));
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['v']->key => $_smarty_tpl->tpl_vars['v']->value) {
                $_smarty_tpl->tpl_vars['v']->_loop = true;
                $_smarty_tpl->tpl_vars['k']->value = $_smarty_tpl->tpl_vars['v']->key;
                ?>
        <?php 
                $_smarty_tpl->tpl_vars['value'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['value']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['v']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['value']->key => $_smarty_tpl->tpl_vars['value']->value) {
                    $_smarty_tpl->tpl_vars['value']->_loop = true;
                    ?>
            <span><a href="<?php 
                    ob_start();
                    echo urlencode($_smarty_tpl->tpl_vars['value']->value);
                    $_tmp7 = ob_get_clean();
                    echo $_smarty_tpl->tpl_vars['link']->value->getPageLink('search', true, null, "tag=" . $_tmp7);
                    ?>
"><?php 
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['value']->value, ENT_QUOTES, 'UTF-8', true);
                    ?>
</a></span>
        <?php 
                }
                ?>
    <?php 
            }
            ?>
</div>
	</div> <!-- end primary_block -->
	<?php 
            if (!$_smarty_tpl->tpl_vars['content_only']->value) {
                if (isset($_smarty_tpl->tpl_vars['quantity_discounts']->value) && count($_smarty_tpl->tpl_vars['quantity_discounts']->value) > 0) {
                    ?>
			<!-- quantity discount -->
			<section class="page-product-box">
				<h3 class="page-product-heading"><?php 
                    echo smartyTranslate(array('s' => 'Volume discounts'), $_smarty_tpl);
                    ?>
</h3>
				<div id="quantityDiscount">
					<table class="std table-product-discounts">
						<thead>
							<tr>
								<th><?php 
                    echo smartyTranslate(array('s' => 'Quantity'), $_smarty_tpl);
                    ?>
</th>
								<th><?php 
                    if ($_smarty_tpl->tpl_vars['display_discount_price']->value) {
                        echo smartyTranslate(array('s' => 'Price'), $_smarty_tpl);
                    } else {
                        echo smartyTranslate(array('s' => 'Discount'), $_smarty_tpl);
                    }
                    ?>
</th>
								<th><?php 
                    echo smartyTranslate(array('s' => 'You Save'), $_smarty_tpl);
                    ?>
</th>
							</tr>
						</thead>
						<tbody>
							<?php 
                    $_smarty_tpl->tpl_vars['quantity_discount'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['quantity_discount']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['quantity_discounts']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['quantity_discount']->key => $_smarty_tpl->tpl_vars['quantity_discount']->value) {
                        $_smarty_tpl->tpl_vars['quantity_discount']->_loop = true;
                        ?>
							<tr id="quantityDiscount_<?php 
                        echo $_smarty_tpl->tpl_vars['quantity_discount']->value['id_product_attribute'];
                        ?>
" class="quantityDiscount_<?php 
                        echo $_smarty_tpl->tpl_vars['quantity_discount']->value['id_product_attribute'];
                        ?>
" data-discount-type="<?php 
                        echo $_smarty_tpl->tpl_vars['quantity_discount']->value['reduction_type'];
                        ?>
" data-discount="<?php 
                        echo floatval($_smarty_tpl->tpl_vars['quantity_discount']->value['real_value']);
                        ?>
" data-discount-quantity="<?php 
                        echo intval($_smarty_tpl->tpl_vars['quantity_discount']->value['quantity']);
                        ?>
">
								<td>
									<?php 
                        echo intval($_smarty_tpl->tpl_vars['quantity_discount']->value['quantity']);
                        ?>

								</td>
								<td>
									<?php 
                        if ($_smarty_tpl->tpl_vars['quantity_discount']->value['price'] >= 0 || $_smarty_tpl->tpl_vars['quantity_discount']->value['reduction_type'] == 'amount') {
                            ?>
										<?php 
                            if ($_smarty_tpl->tpl_vars['display_discount_price']->value) {
                                ?>
											<?php 
                                if ($_smarty_tpl->tpl_vars['quantity_discount']->value['reduction_tax'] == 0 && !$_smarty_tpl->tpl_vars['quantity_discount']->value['price']) {
                                    ?>
												<?php 
                                    echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value) - floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value * $_smarty_tpl->tpl_vars['quantity_discount']->value['reduction_with_tax'])), $_smarty_tpl);
                                    ?>

											<?php 
                                } else {
                                    ?>
												<?php 
                                    echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value) - floatval($_smarty_tpl->tpl_vars['quantity_discount']->value['real_value'])), $_smarty_tpl);
                                    ?>

											<?php 
                                }
                                ?>
										<?php 
                            } else {
                                ?>
											<?php 
                                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => floatval($_smarty_tpl->tpl_vars['quantity_discount']->value['real_value'])), $_smarty_tpl);
                                ?>

										<?php 
                            }
                            ?>
									<?php 
                        } else {
                            ?>
										<?php 
                            if ($_smarty_tpl->tpl_vars['display_discount_price']->value) {
                                ?>
											<?php 
                                if ($_smarty_tpl->tpl_vars['quantity_discount']->value['reduction_tax'] == 0) {
                                    ?>
												<?php 
                                    echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value) - floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value * $_smarty_tpl->tpl_vars['quantity_discount']->value['reduction_with_tax'])), $_smarty_tpl);
                                    ?>

											<?php 
                                } else {
                                    ?>
												<?php 
                                    echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value) - floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value * $_smarty_tpl->tpl_vars['quantity_discount']->value['reduction'])), $_smarty_tpl);
                                    ?>

											<?php 
                                }
                                ?>
										<?php 
                            } else {
                                ?>
											<?php 
                                echo floatval($_smarty_tpl->tpl_vars['quantity_discount']->value['real_value']);
                                ?>
%
										<?php 
                            }
                            ?>
									<?php 
                        }
                        ?>
								</td>
								<td>
									<span><?php 
                        echo smartyTranslate(array('s' => 'Up to'), $_smarty_tpl);
                        ?>
</span>
									<?php 
                        if ($_smarty_tpl->tpl_vars['quantity_discount']->value['price'] >= 0 || $_smarty_tpl->tpl_vars['quantity_discount']->value['reduction_type'] == 'amount') {
                            ?>
										<?php 
                            $_smarty_tpl->tpl_vars['discountPrice'] = new Smarty_variable(floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value) - floatval($_smarty_tpl->tpl_vars['quantity_discount']->value['real_value']), null, 0);
                            ?>
									<?php 
                        } else {
                            ?>
										<?php 
                            $_smarty_tpl->tpl_vars['discountPrice'] = new Smarty_variable(floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value) - floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value * $_smarty_tpl->tpl_vars['quantity_discount']->value['reduction']), null, 0);
                            ?>
									<?php 
                        }
                        ?>
									<?php 
                        $_smarty_tpl->tpl_vars['discountPrice'] = new Smarty_variable($_smarty_tpl->tpl_vars['discountPrice']->value * $_smarty_tpl->tpl_vars['quantity_discount']->value['quantity'], null, 0);
                        ?>
									<?php 
                        $_smarty_tpl->tpl_vars['qtyProductPrice'] = new Smarty_variable(floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value) * $_smarty_tpl->tpl_vars['quantity_discount']->value['quantity'], null, 0);
                        ?>
									<?php 
                        echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['convertPrice'][0][0]->convertPrice(array('price' => $_smarty_tpl->tpl_vars['qtyProductPrice']->value - $_smarty_tpl->tpl_vars['discountPrice']->value), $_smarty_tpl);
                        ?>

								</td>
							</tr>
							<?php 
                    }
                    ?>
						</tbody>
					</table>
				</div>
			</section>
		<?php 
                }
                ?>
		<?php 
                if (isset($_smarty_tpl->tpl_vars['features']->value) && $_smarty_tpl->tpl_vars['features']->value) {
                    ?>
			<!-- Data sheet -->
			<section class="page-product-box">
				<h3 class="page-product-heading"><?php 
                    echo smartyTranslate(array('s' => 'Data sheet'), $_smarty_tpl);
                    ?>
</h3>
				<table class="table-data-sheet">
					<?php 
                    $_smarty_tpl->tpl_vars['feature'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['feature']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['features']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['feature']->key => $_smarty_tpl->tpl_vars['feature']->value) {
                        $_smarty_tpl->tpl_vars['feature']->_loop = true;
                        ?>
					<tr class="<?php 
                        echo smarty_function_cycle(array('values' => "odd,even"), $_smarty_tpl);
                        ?>
">
						<?php 
                        if (isset($_smarty_tpl->tpl_vars['feature']->value['value'])) {
                            ?>
						<td><?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['feature']->value['name'], ENT_QUOTES, 'UTF-8', true);
                            ?>
</td>
						<td><?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['feature']->value['value'], ENT_QUOTES, 'UTF-8', true);
                            ?>
</td>
						<?php 
                        }
                        ?>
					</tr>
					<?php 
                    }
                    ?>
				</table>
			</section>
			<!--end Data sheet -->
		<?php 
                }
                ?>
		<?php 
                if (isset($_smarty_tpl->tpl_vars['product']->value) && $_smarty_tpl->tpl_vars['product']->value->description) {
                    ?>
			<!-- More info -->
			<section class="page-product-box">
				<h3 class="page-product-heading"><?php 
                    echo smartyTranslate(array('s' => 'More info'), $_smarty_tpl);
                    ?>
</h3>
				<!-- full description -->
				<div  class="rte"><?php 
                    echo $_smarty_tpl->tpl_vars['product']->value->description;
                    ?>
</div>
			</section>
			<!--end  More info -->
		<?php 
                }
                ?>
		<?php 
                if (isset($_smarty_tpl->tpl_vars['packItems']->value) && count($_smarty_tpl->tpl_vars['packItems']->value) > 0) {
                    ?>
		<section id="blockpack">
			<h3 class="page-product-heading"><?php 
                    echo smartyTranslate(array('s' => 'Pack content'), $_smarty_tpl);
                    ?>
</h3>
			<?php 
                    echo $_smarty_tpl->getSubTemplate((string) $_smarty_tpl->tpl_vars['tpl_dir']->value . "./product-list.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('products' => $_smarty_tpl->tpl_vars['packItems']->value), 0);
                    ?>

		</section>
		<?php 
                }
                ?>
		<!--HOOK_PRODUCT_TAB -->
		<section class="page-product-box">
			<?php 
                echo $_smarty_tpl->tpl_vars['HOOK_PRODUCT_TAB']->value;
                ?>

			<?php 
                if (isset($_smarty_tpl->tpl_vars['HOOK_PRODUCT_TAB_CONTENT']->value) && $_smarty_tpl->tpl_vars['HOOK_PRODUCT_TAB_CONTENT']->value) {
                    echo $_smarty_tpl->tpl_vars['HOOK_PRODUCT_TAB_CONTENT']->value;
                }
                ?>
		</section>
		<!--end HOOK_PRODUCT_TAB -->
		<?php 
                if (isset($_smarty_tpl->tpl_vars['accessories']->value) && $_smarty_tpl->tpl_vars['accessories']->value) {
                    ?>
			<!--Accessories -->
			<section class="page-product-box">
				<h3 class="page-product-heading"><?php 
                    echo smartyTranslate(array('s' => 'Accessories'), $_smarty_tpl);
                    ?>
</h3>
				<div class="block products_block accessories-block clearfix">
					<div class="block_content">
						<ul id="bxslider" class="bxslider clearfix">
							<?php 
                    $_smarty_tpl->tpl_vars['accessory'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['accessory']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['accessories']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    $_smarty_tpl->tpl_vars['accessory']->total = $_smarty_tpl->_count($_from);
                    $_smarty_tpl->tpl_vars['accessory']->iteration = 0;
                    $_smarty_tpl->tpl_vars['accessory']->index = -1;
                    foreach ($_from as $_smarty_tpl->tpl_vars['accessory']->key => $_smarty_tpl->tpl_vars['accessory']->value) {
                        $_smarty_tpl->tpl_vars['accessory']->_loop = true;
                        $_smarty_tpl->tpl_vars['accessory']->iteration++;
                        $_smarty_tpl->tpl_vars['accessory']->index++;
                        $_smarty_tpl->tpl_vars['accessory']->first = $_smarty_tpl->tpl_vars['accessory']->index === 0;
                        $_smarty_tpl->tpl_vars['accessory']->last = $_smarty_tpl->tpl_vars['accessory']->iteration === $_smarty_tpl->tpl_vars['accessory']->total;
                        $_smarty_tpl->tpl_vars['smarty']->value['foreach']['accessories_list']['first'] = $_smarty_tpl->tpl_vars['accessory']->first;
                        $_smarty_tpl->tpl_vars['smarty']->value['foreach']['accessories_list']['last'] = $_smarty_tpl->tpl_vars['accessory']->last;
                        ?>
								<?php 
                        if (($_smarty_tpl->tpl_vars['accessory']->value['allow_oosp'] || $_smarty_tpl->tpl_vars['accessory']->value['quantity_all_versions'] > 0 || $_smarty_tpl->tpl_vars['accessory']->value['quantity'] > 0) && $_smarty_tpl->tpl_vars['accessory']->value['available_for_order'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value)) {
                            ?>
									<?php 
                            $_smarty_tpl->tpl_vars['accessoryLink'] = new Smarty_variable($_smarty_tpl->tpl_vars['link']->value->getProductLink($_smarty_tpl->tpl_vars['accessory']->value['id_product'], $_smarty_tpl->tpl_vars['accessory']->value['link_rewrite'], $_smarty_tpl->tpl_vars['accessory']->value['category']), null, 0);
                            ?>
									<li class="item product-box ajax_block_product<?php 
                            if ($_smarty_tpl->getVariable('smarty')->value['foreach']['accessories_list']['first']) {
                                ?>
 first_item<?php 
                            } elseif ($_smarty_tpl->getVariable('smarty')->value['foreach']['accessories_list']['last']) {
                                ?>
 last_item<?php 
                            } else {
                                ?>
 item<?php 
                            }
                            ?>
 product_accessories_description">
										<div class="product_desc">
											<a href="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['accessoryLink']->value, ENT_QUOTES, 'UTF-8', true);
                            ?>
" title="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['accessory']->value['legend'], ENT_QUOTES, 'UTF-8', true);
                            ?>
" class="product-image product_image">
												<img class="lazyOwl" src="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getImageLink($_smarty_tpl->tpl_vars['accessory']->value['link_rewrite'], $_smarty_tpl->tpl_vars['accessory']->value['id_image'], 'home_default'), ENT_QUOTES, 'UTF-8', true);
                            ?>
" alt="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['accessory']->value['legend'], ENT_QUOTES, 'UTF-8', true);
                            ?>
" width="<?php 
                            echo $_smarty_tpl->tpl_vars['homeSize']->value['width'];
                            ?>
" height="<?php 
                            echo $_smarty_tpl->tpl_vars['homeSize']->value['height'];
                            ?>
"/>
											</a>
											<div class="block_description">
												<a href="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['accessoryLink']->value, ENT_QUOTES, 'UTF-8', true);
                            ?>
" title="<?php 
                            echo smartyTranslate(array('s' => 'More'), $_smarty_tpl);
                            ?>
" class="product_description">
													<?php 
                            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['truncate'][0][0]->smarty_modifier_truncate(preg_replace('!<[^>]*?>!', ' ', $_smarty_tpl->tpl_vars['accessory']->value['description_short']), 25, '...');
                            ?>

												</a>
											</div>
										</div>
										<div class="s_title_block">
											<h5 itemprop="name" class="product-name">
												<a href="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['accessoryLink']->value, ENT_QUOTES, 'UTF-8', true);
                            ?>
">
													<?php 
                            echo htmlspecialchars($_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['truncate'][0][0]->smarty_modifier_truncate($_smarty_tpl->tpl_vars['accessory']->value['name'], 20, '...', true), ENT_QUOTES, 'UTF-8', true);
                            ?>

												</a>
											</h5>
											<?php 
                            if ($_smarty_tpl->tpl_vars['accessory']->value['show_price'] && !isset($_smarty_tpl->tpl_vars['restricted_country_mode']->value) && !$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value) {
                                ?>
											<span class="price">
												<?php 
                                if ($_smarty_tpl->tpl_vars['priceDisplay']->value != 1) {
                                    ?>
												<?php 
                                    echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['displayWtPrice'][0][0]->displayWtPrice(array('p' => $_smarty_tpl->tpl_vars['accessory']->value['price']), $_smarty_tpl);
                                } else {
                                    echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['displayWtPrice'][0][0]->displayWtPrice(array('p' => $_smarty_tpl->tpl_vars['accessory']->value['price_tax_exc']), $_smarty_tpl);
                                    ?>

												<?php 
                                }
                                ?>
											</span>
											<?php 
                            }
                            ?>
										</div>
										<div class="clearfix" style="margin-top:5px">
											<?php 
                            if (!$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value && ($_smarty_tpl->tpl_vars['accessory']->value['allow_oosp'] || $_smarty_tpl->tpl_vars['accessory']->value['quantity'] > 0)) {
                                ?>
												<div class="no-print">
													<a class="exclusive button ajax_add_to_cart_button" href="<?php 
                                ob_start();
                                echo intval($_smarty_tpl->tpl_vars['accessory']->value['id_product']);
                                $_tmp8 = ob_get_clean();
                                echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('cart', true, null, "qty=1&amp;id_product=" . $_tmp8 . "&amp;token=" . (string) $_smarty_tpl->tpl_vars['static_token']->value . "&amp;add"), ENT_QUOTES, 'UTF-8', true);
                                ?>
" data-id-product="<?php 
                                echo intval($_smarty_tpl->tpl_vars['accessory']->value['id_product']);
                                ?>
" title="<?php 
                                echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl);
                                ?>
">
														<span><?php 
                                echo smartyTranslate(array('s' => 'Add to cart'), $_smarty_tpl);
                                ?>
</span>
													</a>
												</div>
											<?php 
                            }
                            ?>
										</div>
									</li>
								<?php 
                        }
                        ?>
							<?php 
                    }
                    ?>
						</ul>
					</div>
				</div>
			</section>
			<!--end Accessories -->
		<?php 
                }
                ?>
		<?php 
                if (isset($_smarty_tpl->tpl_vars['HOOK_PRODUCT_FOOTER']->value) && $_smarty_tpl->tpl_vars['HOOK_PRODUCT_FOOTER']->value) {
                    echo $_smarty_tpl->tpl_vars['HOOK_PRODUCT_FOOTER']->value;
                }
                ?>
		<!-- description & features -->
		<?php 
                if (isset($_smarty_tpl->tpl_vars['product']->value) && $_smarty_tpl->tpl_vars['product']->value->description || isset($_smarty_tpl->tpl_vars['features']->value) && $_smarty_tpl->tpl_vars['features']->value || isset($_smarty_tpl->tpl_vars['accessories']->value) && $_smarty_tpl->tpl_vars['accessories']->value || isset($_smarty_tpl->tpl_vars['HOOK_PRODUCT_TAB']->value) && $_smarty_tpl->tpl_vars['HOOK_PRODUCT_TAB']->value || isset($_smarty_tpl->tpl_vars['attachments']->value) && $_smarty_tpl->tpl_vars['attachments']->value || isset($_smarty_tpl->tpl_vars['product']->value) && $_smarty_tpl->tpl_vars['product']->value->customizable) {
                    ?>
			<?php 
                    if (isset($_smarty_tpl->tpl_vars['attachments']->value) && $_smarty_tpl->tpl_vars['attachments']->value) {
                        ?>
			<!--Download -->
			<section class="page-product-box">
				<h3 class="page-product-heading"><?php 
                        echo smartyTranslate(array('s' => 'Download'), $_smarty_tpl);
                        ?>
</h3>
				<?php 
                        $_smarty_tpl->tpl_vars['attachment'] = new Smarty_Variable();
                        $_smarty_tpl->tpl_vars['attachment']->_loop = false;
                        $_from = $_smarty_tpl->tpl_vars['attachments']->value;
                        if (!is_array($_from) && !is_object($_from)) {
                            settype($_from, 'array');
                        }
                        $_smarty_tpl->tpl_vars['attachment']->total = $_smarty_tpl->_count($_from);
                        $_smarty_tpl->tpl_vars['attachment']->iteration = 0;
                        $_smarty_tpl->tpl_vars['smarty']->value['foreach']['attachements']['iteration'] = 0;
                        foreach ($_from as $_smarty_tpl->tpl_vars['attachment']->key => $_smarty_tpl->tpl_vars['attachment']->value) {
                            $_smarty_tpl->tpl_vars['attachment']->_loop = true;
                            $_smarty_tpl->tpl_vars['attachment']->iteration++;
                            $_smarty_tpl->tpl_vars['attachment']->last = $_smarty_tpl->tpl_vars['attachment']->iteration === $_smarty_tpl->tpl_vars['attachment']->total;
                            $_smarty_tpl->tpl_vars['smarty']->value['foreach']['attachements']['iteration']++;
                            $_smarty_tpl->tpl_vars['smarty']->value['foreach']['attachements']['last'] = $_smarty_tpl->tpl_vars['attachment']->last;
                            ?>
					<?php 
                            if ($_smarty_tpl->getVariable('smarty')->value['foreach']['attachements']['iteration'] % 3 == 1) {
                                ?>
<div class="row"><?php 
                            }
                            ?>
						<div class="col-lg-4">
							<h4><a href="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('attachment', true, null, "id_attachment=" . (string) $_smarty_tpl->tpl_vars['attachment']->value['id_attachment']), ENT_QUOTES, 'UTF-8', true);
                            ?>
"><?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['attachment']->value['name'], ENT_QUOTES, 'UTF-8', true);
                            ?>
</a></h4>
							<p class="text-muted"><?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['attachment']->value['description'], ENT_QUOTES, 'UTF-8', true);
                            ?>
</p>
							<a class="btn btn-default btn-block" href="<?php 
                            echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getPageLink('attachment', true, null, "id_attachment=" . (string) $_smarty_tpl->tpl_vars['attachment']->value['id_attachment']), ENT_QUOTES, 'UTF-8', true);
                            ?>
">
								<i class="icon-download"></i>
								<?php 
                            echo smartyTranslate(array('s' => "Download"), $_smarty_tpl);
                            ?>
 (<?php 
                            echo Tools::formatBytes($_smarty_tpl->tpl_vars['attachment']->value['file_size'], 2);
                            ?>
)
							</a>
							<hr />
						</div>
					<?php 
                            if ($_smarty_tpl->getVariable('smarty')->value['foreach']['attachements']['iteration'] % 3 == 0 || $_smarty_tpl->getVariable('smarty')->value['foreach']['attachements']['last']) {
                                ?>
</div><?php 
                            }
                            ?>
				<?php 
                        }
                        ?>
			</section>
			<!--end Download -->
			<?php 
                    }
                    ?>
			<?php 
                    if (isset($_smarty_tpl->tpl_vars['product']->value) && $_smarty_tpl->tpl_vars['product']->value->customizable) {
                        ?>
			<!--Customization -->
			<section class="page-product-box">
				<h3 class="page-product-heading"><?php 
                        echo smartyTranslate(array('s' => 'Product customization'), $_smarty_tpl);
                        ?>
</h3>
				<!-- Customizable products -->
				<form method="post" action="<?php 
                        echo $_smarty_tpl->tpl_vars['customizationFormTarget']->value;
                        ?>
" enctype="multipart/form-data" id="customizationForm" class="clearfix">
					<p class="infoCustomizable">
						<?php 
                        echo smartyTranslate(array('s' => 'After saving your customized product, remember to add it to your cart.'), $_smarty_tpl);
                        ?>

						<?php 
                        if ($_smarty_tpl->tpl_vars['product']->value->uploadable_files) {
                            ?>
						<br />
						<?php 
                            echo smartyTranslate(array('s' => 'Allowed file formats are: GIF, JPG, PNG'), $_smarty_tpl);
                        }
                        ?>
					</p>
					<?php 
                        if (intval($_smarty_tpl->tpl_vars['product']->value->uploadable_files)) {
                            ?>
						<div class="customizableProductsFile">
							<h5 class="product-heading-h5"><?php 
                            echo smartyTranslate(array('s' => 'Pictures'), $_smarty_tpl);
                            ?>
</h5>
							<ul id="uploadable_files" class="clearfix">
								<?php 
                            echo smarty_function_counter(array('start' => 0, 'assign' => 'customizationField'), $_smarty_tpl);
                            ?>

								<?php 
                            $_smarty_tpl->tpl_vars['field'] = new Smarty_Variable();
                            $_smarty_tpl->tpl_vars['field']->_loop = false;
                            $_from = $_smarty_tpl->tpl_vars['customizationFields']->value;
                            if (!is_array($_from) && !is_object($_from)) {
                                settype($_from, 'array');
                            }
                            foreach ($_from as $_smarty_tpl->tpl_vars['field']->key => $_smarty_tpl->tpl_vars['field']->value) {
                                $_smarty_tpl->tpl_vars['field']->_loop = true;
                                ?>
									<?php 
                                if ($_smarty_tpl->tpl_vars['field']->value['type'] == 0) {
                                    ?>
										<li class="customizationUploadLine<?php 
                                    if ($_smarty_tpl->tpl_vars['field']->value['required']) {
                                        ?>
 required<?php 
                                    }
                                    ?>
"><?php 
                                    $_smarty_tpl->tpl_vars['key'] = new Smarty_variable('pictures_' . $_smarty_tpl->tpl_vars['product']->value->id . '_' . $_smarty_tpl->tpl_vars['field']->value['id_customization_field'], null, 0);
                                    ?>
											<?php 
                                    if (isset($_smarty_tpl->tpl_vars['pictures']->value[$_smarty_tpl->tpl_vars['key']->value])) {
                                        ?>
												<div class="customizationUploadBrowse">
													<img src="<?php 
                                        echo $_smarty_tpl->tpl_vars['pic_dir']->value;
                                        echo $_smarty_tpl->tpl_vars['pictures']->value[$_smarty_tpl->tpl_vars['key']->value];
                                        ?>
_small" alt="" />
														<a href="<?php 
                                        echo htmlspecialchars($_smarty_tpl->tpl_vars['link']->value->getProductDeletePictureLink($_smarty_tpl->tpl_vars['product']->value, $_smarty_tpl->tpl_vars['field']->value['id_customization_field']), ENT_QUOTES, 'UTF-8', true);
                                        ?>
" title="<?php 
                                        echo smartyTranslate(array('s' => 'Delete'), $_smarty_tpl);
                                        ?>
" >
															<img src="<?php 
                                        echo $_smarty_tpl->tpl_vars['img_dir']->value;
                                        ?>
icon/delete.gif" alt="<?php 
                                        echo smartyTranslate(array('s' => 'Delete'), $_smarty_tpl);
                                        ?>
" class="customization_delete_icon" width="11" height="13" />
														</a>
												</div>
											<?php 
                                    }
                                    ?>
											<div class="customizationUploadBrowse form-group">
												<label class="customizationUploadBrowseDescription">
													<?php 
                                    if (!empty($_smarty_tpl->tpl_vars['field']->value['name'])) {
                                        ?>
														<?php 
                                        echo $_smarty_tpl->tpl_vars['field']->value['name'];
                                        ?>

													<?php 
                                    } else {
                                        ?>
														<?php 
                                        echo smartyTranslate(array('s' => 'Please select an image file from your computer'), $_smarty_tpl);
                                        ?>

													<?php 
                                    }
                                    ?>
													<?php 
                                    if ($_smarty_tpl->tpl_vars['field']->value['required']) {
                                        ?>
<sup>*</sup><?php 
                                    }
                                    ?>
												</label>
												<input type="file" name="file<?php 
                                    echo $_smarty_tpl->tpl_vars['field']->value['id_customization_field'];
                                    ?>
" id="img<?php 
                                    echo $_smarty_tpl->tpl_vars['customizationField']->value;
                                    ?>
" class="form-control customization_block_input <?php 
                                    if (isset($_smarty_tpl->tpl_vars['pictures']->value[$_smarty_tpl->tpl_vars['key']->value])) {
                                        ?>
filled<?php 
                                    }
                                    ?>
" />
											</div>
										</li>
										<?php 
                                    echo smarty_function_counter(array(), $_smarty_tpl);
                                    ?>

									<?php 
                                }
                                ?>
								<?php 
                            }
                            ?>
							</ul>
						</div>
					<?php 
                        }
                        ?>
					<?php 
                        if (intval($_smarty_tpl->tpl_vars['product']->value->text_fields)) {
                            ?>
						<div class="customizableProductsText">
							<h5 class="product-heading-h5"><?php 
                            echo smartyTranslate(array('s' => 'Text'), $_smarty_tpl);
                            ?>
</h5>
							<ul id="text_fields">
							<?php 
                            echo smarty_function_counter(array('start' => 0, 'assign' => 'customizationField'), $_smarty_tpl);
                            ?>

							<?php 
                            $_smarty_tpl->tpl_vars['field'] = new Smarty_Variable();
                            $_smarty_tpl->tpl_vars['field']->_loop = false;
                            $_from = $_smarty_tpl->tpl_vars['customizationFields']->value;
                            if (!is_array($_from) && !is_object($_from)) {
                                settype($_from, 'array');
                            }
                            foreach ($_from as $_smarty_tpl->tpl_vars['field']->key => $_smarty_tpl->tpl_vars['field']->value) {
                                $_smarty_tpl->tpl_vars['field']->_loop = true;
                                ?>
								<?php 
                                if ($_smarty_tpl->tpl_vars['field']->value['type'] == 1) {
                                    ?>
									<li class="customizationUploadLine<?php 
                                    if ($_smarty_tpl->tpl_vars['field']->value['required']) {
                                        ?>
 required<?php 
                                    }
                                    ?>
">
										<label for ="textField<?php 
                                    echo $_smarty_tpl->tpl_vars['customizationField']->value;
                                    ?>
">
											<?php 
                                    $_smarty_tpl->tpl_vars['key'] = new Smarty_variable('textFields_' . $_smarty_tpl->tpl_vars['product']->value->id . '_' . $_smarty_tpl->tpl_vars['field']->value['id_customization_field'], null, 0);
                                    ?>
											<?php 
                                    if (!empty($_smarty_tpl->tpl_vars['field']->value['name'])) {
                                        ?>
												<?php 
                                        echo $_smarty_tpl->tpl_vars['field']->value['name'];
                                        ?>

											<?php 
                                    }
                                    ?>
											<?php 
                                    if ($_smarty_tpl->tpl_vars['field']->value['required']) {
                                        ?>
<sup>*</sup><?php 
                                    }
                                    ?>
										</label>
										<textarea name="textField<?php 
                                    echo $_smarty_tpl->tpl_vars['field']->value['id_customization_field'];
                                    ?>
" class="form-control customization_block_input" id="textField<?php 
                                    echo $_smarty_tpl->tpl_vars['customizationField']->value;
                                    ?>
" rows="3" cols="20"><?php 
                                    if (isset($_smarty_tpl->tpl_vars['textFields']->value[$_smarty_tpl->tpl_vars['key']->value])) {
                                        echo stripslashes($_smarty_tpl->tpl_vars['textFields']->value[$_smarty_tpl->tpl_vars['key']->value]);
                                    }
                                    ?>
</textarea>
									</li>
									<?php 
                                    echo smarty_function_counter(array(), $_smarty_tpl);
                                    ?>

								<?php 
                                }
                                ?>
							<?php 
                            }
                            ?>
							</ul>
						</div>
					<?php 
                        }
                        ?>
					<p id="customizedDatas">
						<input type="hidden" name="quantityBackup" id="quantityBackup" value="" />
						<input type="hidden" name="submitCustomizedDatas" value="1" />
						<button class="button btn btn-default button button-small" name="saveCustomization">
							<span><?php 
                        echo smartyTranslate(array('s' => 'Save'), $_smarty_tpl);
                        ?>
</span>
						</button>
						<span id="ajax-loader" class="unvisible">
							<img src="<?php 
                        echo $_smarty_tpl->tpl_vars['img_ps_dir']->value;
                        ?>
loader.gif" alt="loader" />
						</span>
					</p>
				</form>
				<p class="clear required"><sup>*</sup> <?php 
                        echo smartyTranslate(array('s' => 'required fields'), $_smarty_tpl);
                        ?>
</p>
			</section>
			<!--end Customization -->
			<?php 
                    }
                    ?>
		<?php 
                }
                ?>
	<?php 
            }
            ?>
</div> <!-- itemscope product wrapper -->
<?php 
            if (isset($_GET['ad']) && $_GET['ad']) {
                $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'ad'));
                $_block_repeat = true;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'ad'), null, $_smarty_tpl, $_block_repeat);
                while ($_block_repeat) {
                    ob_start();
                    echo htmlspecialchars($_smarty_tpl->tpl_vars['base_dir']->value . $_GET['ad'], ENT_QUOTES, 'UTF-8', true);
                    $_block_content = ob_get_clean();
                    $_block_repeat = false;
                    echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'ad'), $_block_content, $_smarty_tpl, $_block_repeat);
                }
                array_pop($_smarty_tpl->smarty->_tag_stack);
            }
            if (isset($_GET['adtoken']) && $_GET['adtoken']) {
                $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'adtoken'));
                $_block_repeat = true;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'adtoken'), null, $_smarty_tpl, $_block_repeat);
                while ($_block_repeat) {
                    ob_start();
                    echo htmlspecialchars($_GET['adtoken'], ENT_QUOTES, 'UTF-8', true);
                    $_block_content = ob_get_clean();
                    $_block_repeat = false;
                    echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'adtoken'), $_block_content, $_smarty_tpl, $_block_repeat);
                }
                array_pop($_smarty_tpl->smarty->_tag_stack);
            }
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('allowBuyWhenOutOfStock' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval($_smarty_tpl->tpl_vars['allow_oosp']->value)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('availableNowValue' => preg_replace("%(?<!\\\\)'%", "\\'", $_smarty_tpl->tpl_vars['product']->value->available_now)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('availableLaterValue' => preg_replace("%(?<!\\\\)'%", "\\'", $_smarty_tpl->tpl_vars['product']->value->available_later)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('attribute_anchor_separator' => preg_replace("%(?<!\\\\)'%", "\\'", $_smarty_tpl->tpl_vars['attribute_anchor_separator']->value)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('attributesCombinations' => $_smarty_tpl->tpl_vars['attributesCombinations']->value), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('currentDate' => smarty_modifier_date_format(time(), '%Y-%m-%d %H:%M:%S')), $_smarty_tpl);
            if (isset($_smarty_tpl->tpl_vars['combinations']->value) && $_smarty_tpl->tpl_vars['combinations']->value) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('combinations' => $_smarty_tpl->tpl_vars['combinations']->value), $_smarty_tpl);
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('combinationsFromController' => $_smarty_tpl->tpl_vars['combinations']->value), $_smarty_tpl);
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('displayDiscountPrice' => $_smarty_tpl->tpl_vars['display_discount_price']->value), $_smarty_tpl);
                $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'upToTxt'));
                $_block_repeat = true;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'upToTxt'), null, $_smarty_tpl, $_block_repeat);
                while ($_block_repeat) {
                    ob_start();
                    echo smartyTranslate(array('s' => 'Up to', 'js' => 1), $_smarty_tpl);
                    $_block_content = ob_get_clean();
                    $_block_repeat = false;
                    echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'upToTxt'), $_block_content, $_smarty_tpl, $_block_repeat);
                }
                array_pop($_smarty_tpl->smarty->_tag_stack);
            }
            if (isset($_smarty_tpl->tpl_vars['combinationImages']->value) && $_smarty_tpl->tpl_vars['combinationImages']->value) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('combinationImages' => $_smarty_tpl->tpl_vars['combinationImages']->value), $_smarty_tpl);
            }
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('customizationId' => $_smarty_tpl->tpl_vars['id_customization']->value), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('customizationFields' => $_smarty_tpl->tpl_vars['customizationFields']->value), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('default_eco_tax' => floatval($_smarty_tpl->tpl_vars['product']->value->ecotax)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('displayPrice' => intval($_smarty_tpl->tpl_vars['priceDisplay']->value)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('ecotaxTax_rate' => floatval($_smarty_tpl->tpl_vars['ecotaxTax_rate']->value)), $_smarty_tpl);
            if (isset($_smarty_tpl->tpl_vars['cover']->value['id_image_only'])) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('idDefaultImage' => intval($_smarty_tpl->tpl_vars['cover']->value['id_image_only'])), $_smarty_tpl);
            } else {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('idDefaultImage' => 0), $_smarty_tpl);
            }
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('img_ps_dir' => $_smarty_tpl->tpl_vars['img_ps_dir']->value), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('img_prod_dir' => $_smarty_tpl->tpl_vars['img_prod_dir']->value), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('id_product' => intval($_smarty_tpl->tpl_vars['product']->value->id)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('jqZoomEnabled' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval($_smarty_tpl->tpl_vars['jqZoomEnabled']->value)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('maxQuantityToAllowDisplayOfLastQuantityMessage' => intval($_smarty_tpl->tpl_vars['last_qties']->value)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('minimalQuantity' => intval($_smarty_tpl->tpl_vars['product']->value->minimal_quantity)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('noTaxForThisProduct' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval($_smarty_tpl->tpl_vars['no_tax']->value)), $_smarty_tpl);
            if (isset($_smarty_tpl->tpl_vars['customer_group_without_tax']->value)) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('customerGroupWithoutTax' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval($_smarty_tpl->tpl_vars['customer_group_without_tax']->value)), $_smarty_tpl);
            } else {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('customerGroupWithoutTax' => false), $_smarty_tpl);
            }
            if (isset($_smarty_tpl->tpl_vars['group_reduction']->value)) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('groupReduction' => floatval($_smarty_tpl->tpl_vars['group_reduction']->value)), $_smarty_tpl);
            } else {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('groupReduction' => false), $_smarty_tpl);
            }
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('oosHookJsCodeFunctions' => array()), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productHasAttributes' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval(isset($_smarty_tpl->tpl_vars['groups']->value))), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productPriceTaxExcluded' => floatval((($tmp = @$_smarty_tpl->tpl_vars['product']->value->getPriceWithoutReduct(true)) === null || $tmp === '' ? 'null' : $tmp) - $_smarty_tpl->tpl_vars['product']->value->ecotax)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productPriceTaxIncluded' => floatval((($tmp = @$_smarty_tpl->tpl_vars['product']->value->getPriceWithoutReduct(false)) === null || $tmp === '' ? 'null' : $tmp) - $_smarty_tpl->tpl_vars['product']->value->ecotax * (1 + $_smarty_tpl->tpl_vars['ecotaxTax_rate']->value / 100))), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productBasePriceTaxExcluded' => floatval($_smarty_tpl->tpl_vars['product']->value->getPrice(false, null, 6, null, false, false) - $_smarty_tpl->tpl_vars['product']->value->ecotax)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productBasePriceTaxExcl' => floatval($_smarty_tpl->tpl_vars['product']->value->getPrice(false, null, 6, null, false, false))), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productBasePriceTaxIncl' => floatval($_smarty_tpl->tpl_vars['product']->value->getPrice(true, null, 6, null, false, false))), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productReference' => htmlspecialchars($_smarty_tpl->tpl_vars['product']->value->reference, ENT_QUOTES, 'UTF-8', true)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productAvailableForOrder' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval($_smarty_tpl->tpl_vars['product']->value->available_for_order)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productPriceWithoutReduction' => floatval($_smarty_tpl->tpl_vars['productPriceWithoutReduction']->value)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productPrice' => floatval($_smarty_tpl->tpl_vars['productPrice']->value)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productUnitPriceRatio' => floatval($_smarty_tpl->tpl_vars['product']->value->unit_price_ratio)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('productShowPrice' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval(!$_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value && $_smarty_tpl->tpl_vars['product']->value->show_price)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('PS_CATALOG_MODE' => $_smarty_tpl->tpl_vars['PS_CATALOG_MODE']->value), $_smarty_tpl);
            if ($_smarty_tpl->tpl_vars['product']->value->specificPrice && count($_smarty_tpl->tpl_vars['product']->value->specificPrice)) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('product_specific_price' => $_smarty_tpl->tpl_vars['product']->value->specificPrice), $_smarty_tpl);
            } else {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('product_specific_price' => array()), $_smarty_tpl);
            }
            if ($_smarty_tpl->tpl_vars['display_qties']->value == 1 && $_smarty_tpl->tpl_vars['product']->value->quantity) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('quantityAvailable' => $_smarty_tpl->tpl_vars['product']->value->quantity), $_smarty_tpl);
            } else {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('quantityAvailable' => 0), $_smarty_tpl);
            }
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('quantitiesDisplayAllowed' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval($_smarty_tpl->tpl_vars['display_qties']->value)), $_smarty_tpl);
            if ($_smarty_tpl->tpl_vars['product']->value->specificPrice && $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction'] && $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction_type'] == 'percentage') {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('reduction_percent' => $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction'] * floatval(100)), $_smarty_tpl);
            } else {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('reduction_percent' => 0), $_smarty_tpl);
            }
            if ($_smarty_tpl->tpl_vars['product']->value->specificPrice && $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction'] && $_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction_type'] == 'amount') {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('reduction_price' => floatval($_smarty_tpl->tpl_vars['product']->value->specificPrice['reduction'])), $_smarty_tpl);
            } else {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('reduction_price' => 0), $_smarty_tpl);
            }
            if ($_smarty_tpl->tpl_vars['product']->value->specificPrice && $_smarty_tpl->tpl_vars['product']->value->specificPrice['price']) {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('specific_price' => floatval($_smarty_tpl->tpl_vars['product']->value->specificPrice['price'])), $_smarty_tpl);
            } else {
                echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('specific_price' => 0), $_smarty_tpl);
            }
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('specific_currency' => $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['boolval'][0][0]->boolval($_smarty_tpl->tpl_vars['product']->value->specificPrice && $_smarty_tpl->tpl_vars['product']->value->specificPrice['id_currency'])), $_smarty_tpl);
            ?>
 <?php 
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('stock_management' => intval($_smarty_tpl->tpl_vars['PS_STOCK_MANAGEMENT']->value)), $_smarty_tpl);
            echo $_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['addJsDef'][0][0]->addJsDef(array('taxRate' => floatval($_smarty_tpl->tpl_vars['tax_rate']->value)), $_smarty_tpl);
            $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'doesntExist'));
            $_block_repeat = true;
            echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'doesntExist'), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                echo smartyTranslate(array('s' => 'This combination does not exist for this product. Please select another combination.', 'js' => 1), $_smarty_tpl);
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'doesntExist'), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'doesntExistNoMore'));
            $_block_repeat = true;
            echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'doesntExistNoMore'), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                echo smartyTranslate(array('s' => 'This product is no longer in stock', 'js' => 1), $_smarty_tpl);
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'doesntExistNoMore'), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'doesntExistNoMoreBut'));
            $_block_repeat = true;
            echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'doesntExistNoMoreBut'), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                echo smartyTranslate(array('s' => 'with those attributes but is available with others.', 'js' => 1), $_smarty_tpl);
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'doesntExistNoMoreBut'), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'fieldRequired'));
            $_block_repeat = true;
            echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'fieldRequired'), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                echo smartyTranslate(array('s' => 'Please fill in all the required fields before saving your customization.', 'js' => 1), $_smarty_tpl);
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'fieldRequired'), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'uploading_in_progress'));
            $_block_repeat = true;
            echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'uploading_in_progress'), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                echo smartyTranslate(array('s' => 'Uploading in progress, please be patient.', 'js' => 1), $_smarty_tpl);
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'uploading_in_progress'), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'product_fileDefaultHtml'));
            $_block_repeat = true;
            echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'product_fileDefaultHtml'), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                echo smartyTranslate(array('s' => 'No file selected', 'js' => 1), $_smarty_tpl);
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'product_fileDefaultHtml'), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            $_smarty_tpl->smarty->_tag_stack[] = array('addJsDefL', array('name' => 'product_fileButtonHtml'));
            $_block_repeat = true;
            echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'product_fileButtonHtml'), null, $_smarty_tpl, $_block_repeat);
            while ($_block_repeat) {
                ob_start();
                echo smartyTranslate(array('s' => 'Choose File', 'js' => 1), $_smarty_tpl);
                $_block_content = ob_get_clean();
                $_block_repeat = false;
                echo $_smarty_tpl->smarty->registered_plugins['block']['addJsDefL'][0][0]->addJsDefL(array('name' => 'product_fileButtonHtml'), $_block_content, $_smarty_tpl, $_block_repeat);
            }
            array_pop($_smarty_tpl->smarty->_tag_stack);
            ?>

<?php 
        }
    }
示例#11
0
 public function __construct($id_product = NULL, $full = false, $id_lang = NULL)
 {
     parent::__construct($id_product, $id_lang);
     if ($full and $this->id) {
         $this->manufacturer_name = Manufacturer::getNameById(intval($this->id_manufacturer));
         $this->supplier_name = Supplier::getNameById(intval($this->id_supplier));
         $tax = new Tax(intval($this->id_tax), intval($id_lang));
         $this->tax_name = $tax->name;
         $this->tax_rate = floatval($tax->rate);
         $this->new = $this->isNew();
     }
     if ($this->id_category_default) {
         $this->category = Category::getLinkRewrite(intval($this->id_category_default), intval($id_lang));
     }
     if ($this->id) {
         $this->tags = Tag::getProductTags(intval($this->id));
     }
 }
    public function productImport()
    {
        $this->receiveTab();
        $handle = $this->openCsvFile();
        $default_language_id = (int) Configuration::get('PS_LANG_DEFAULT');
        $id_lang = Language::getIdByIso(Tools::getValue('iso_lang'));
        if (!Validate::isUnsignedId($id_lang)) {
            $id_lang = $default_language_id;
        }
        AdminImportController::setLocale();
        $shop_ids = Shop::getCompleteListOfShopsID();
        for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
            if (Tools::getValue('convert')) {
                $line = $this->utf8EncodeArray($line);
            }
            $info = AdminImportController::getMaskedRow($line);
            if (self::ignoreRow($info)) {
                continue;
            }
            if (Tools::getValue('forceIDs') && isset($info['id']) && (int) $info['id']) {
                $product = new Product((int) $info['id']);
            } elseif (Tools::getValue('match_ref') && array_key_exists('reference', $info)) {
                $datas = Db::getInstance()->getRow('
						SELECT p.`id_product`
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE p.`reference` = "' . pSQL($info['reference']) . '"
					');
                if (isset($datas['id_product']) && $datas['id_product']) {
                    $product = new Product((int) $datas['id_product']);
                } else {
                    $product = new Product();
                }
            } else {
                if (array_key_exists('id', $info) && is_string($info['id'])) {
                    $prod = self::findProductByName($default_language_id, $info['id'], $info['name']);
                    if ($prod['id_product']) {
                        $info['id'] = (int) $prod['id_product'];
                    }
                }
                if (array_key_exists('id', $info) && (int) $info['id'] && Product::existsInDatabase((int) $info['id'], 'product')) {
                    $product = new Product((int) $info['id']);
                    $product->loadStockData();
                    $category_data = Product::getProductCategories((int) $product->id);
                    if (is_array($category_data)) {
                        foreach ($category_data as $tmp) {
                            if (!isset($product->category) || !$product->category || is_array($product->category)) {
                                $product->category[] = $tmp;
                            }
                        }
                    }
                } else {
                    $product = new Product();
                }
            }
            AdminImportController::setEntityDefaultValues($product);
            AdminImportController::arrayWalk($info, array('AdminImportController', 'fillInfo'), $product);
            if (!Shop::isFeatureActive()) {
                $product->shop = 1;
            } elseif (!isset($product->shop) || empty($product->shop)) {
                $product->shop = implode($this->multiple_value_separator, Shop::getContextListShopID());
            }
            if (!Shop::isFeatureActive()) {
                $product->id_shop_default = 1;
            } else {
                $product->id_shop_default = (int) Context::getContext()->shop->id;
            }
            $product->id_shop_list = array();
            foreach (explode($this->multiple_value_separator, $product->shop) as $shop) {
                if (!empty($shop) && !is_numeric($shop)) {
                    $product->id_shop_list[] = Shop::getIdByName($shop);
                } elseif (!empty($shop)) {
                    $product->id_shop_list[] = $shop;
                }
            }
            if ((int) $product->id_tax_rules_group != 0) {
                if (Validate::isLoadedObject(new TaxRulesGroup($product->id_tax_rules_group))) {
                    $address = $this->context->shop->getAddress();
                    $tax_manager = TaxManagerFactory::getManager($address, $product->id_tax_rules_group);
                    $product_tax_calculator = $tax_manager->getTaxCalculator();
                    $product->tax_rate = $product_tax_calculator->getTotalRate();
                } else {
                    $this->addProductWarning('id_tax_rules_group', $product->id_tax_rules_group, Tools::displayError('Invalid tax rule group ID. You first need to create a group with this ID.'));
                }
            }
            if (isset($product->manufacturer) && is_numeric($product->manufacturer) && Manufacturer::manufacturerExists((int) $product->manufacturer)) {
                $product->id_manufacturer = (int) $product->manufacturer;
            } elseif (isset($product->manufacturer) && is_string($product->manufacturer) && !empty($product->manufacturer)) {
                if ($manufacturer = Manufacturer::getIdByName($product->manufacturer)) {
                    $product->id_manufacturer = (int) $manufacturer;
                } else {
                    $manufacturer = new Manufacturer();
                    $manufacturer->name = $product->manufacturer;
                    if (($field_error = $manufacturer->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $manufacturer->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $manufacturer->add()) {
                        $product->id_manufacturer = (int) $manufacturer->id;
                    } else {
                        $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $manufacturer->name, isset($manufacturer->id) && !empty($manufacturer->id) ? $manufacturer->id : 'null');
                        $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                    }
                }
            }
            if (isset($product->supplier) && is_numeric($product->supplier) && Supplier::supplierExists((int) $product->supplier)) {
                $product->id_supplier = (int) $product->supplier;
            } elseif (isset($product->supplier) && is_string($product->supplier) && !empty($product->supplier)) {
                if ($supplier = Supplier::getIdByName($product->supplier)) {
                    $product->id_supplier = (int) $supplier;
                } else {
                    $supplier = new Supplier();
                    $supplier->name = $product->supplier;
                    $supplier->active = true;
                    if (($field_error = $supplier->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $supplier->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $supplier->add()) {
                        $product->id_supplier = (int) $supplier->id;
                        $supplier->associateTo($product->id_shop_list);
                    } else {
                        $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $supplier->name, isset($supplier->id) && !empty($supplier->id) ? $supplier->id : 'null');
                        $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                    }
                }
            }
            if (isset($product->price_tex) && !isset($product->price_tin)) {
                $product->price = $product->price_tex;
            } elseif (isset($product->price_tin) && !isset($product->price_tex)) {
                $product->price = $product->price_tin;
                if ($product->tax_rate) {
                    $product->price = (double) number_format($product->price / (1 + $product->tax_rate / 100), 6, '.', '');
                }
            } elseif (isset($product->price_tin) && isset($product->price_tex)) {
                $product->price = $product->price_tex;
            }
            if (!Configuration::get('PS_USE_ECOTAX')) {
                $product->ecotax = 0;
            }
            $properties = $product->productProperties();
            if ((double) $properties['pp_unit_price_ratio'] > 0) {
                $product->unit_price = (double) $product->price / (double) $properties['pp_unit_price_ratio'];
            }
            if (isset($product->category) && is_array($product->category) && count($product->category)) {
                $product->id_category = array();
                foreach ($product->category as $value) {
                    if (is_numeric($value)) {
                        if (Category::categoryExists((int) $value)) {
                            $product->id_category[] = (int) $value;
                        } else {
                            $category_to_create = new Category();
                            $category_to_create->id = (int) $value;
                            $category_to_create->name = AdminImportController::createMultiLangField($value);
                            $category_to_create->active = 1;
                            $category_to_create->id_parent = Configuration::get('PS_HOME_CATEGORY');
                            $category_link_rewrite = Tools::link_rewrite($category_to_create->name[$default_language_id]);
                            $category_to_create->link_rewrite = AdminImportController::createMultiLangField($category_link_rewrite);
                            if (($field_error = $category_to_create->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $category_to_create->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $category_to_create->add()) {
                                $product->id_category[] = (int) $category_to_create->id;
                            } else {
                                $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), $category_to_create->name[$default_language_id], isset($category_to_create->id) && !empty($category_to_create->id) ? $category_to_create->id : 'null');
                                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
                            }
                        }
                    } elseif (is_string($value) && !empty($value)) {
                        $category = Category::searchByPath($default_language_id, trim($value), $this, 'productImportCreateCat');
                        if ($category['id_category']) {
                            $product->id_category[] = (int) $category['id_category'];
                        } else {
                            $this->errors[] = sprintf(Tools::displayError('%1$s cannot be saved'), trim($value));
                        }
                    }
                }
                $product->id_category = array_values(array_unique($product->id_category));
            }
            if (!isset($product->id_category_default) || !$product->id_category_default) {
                $product->id_category_default = isset($product->id_category[0]) ? (int) $product->id_category[0] : (int) Configuration::get('PS_HOME_CATEGORY');
            }
            $link_rewrite = is_array($product->link_rewrite) && isset($product->link_rewrite[$id_lang]) ? trim($product->link_rewrite[$id_lang]) : '';
            $valid_link = Validate::isLinkRewrite($link_rewrite);
            if (isset($product->link_rewrite[$id_lang]) && empty($product->link_rewrite[$id_lang]) || !$valid_link) {
                $link_rewrite = Tools::link_rewrite($product->name[$id_lang]);
                if ($link_rewrite == '') {
                    $link_rewrite = 'friendly-url-autogeneration-failed';
                }
            }
            if (!$valid_link) {
                $this->warnings[] = sprintf(Tools::displayError('Rewrite link for %1$s (ID: %2$s) was re-written as %3$s.'), $product->name[$id_lang], isset($info['id']) && !empty($info['id']) ? $info['id'] : 'null', $link_rewrite);
            }
            if (!(Tools::getValue('match_ref') || Tools::getValue('forceIDs')) || !(is_array($product->link_rewrite) && count($product->link_rewrite) && !empty($product->link_rewrite[$id_lang]))) {
                $product->link_rewrite = AdminImportController::createMultiLangField($link_rewrite);
            }
            if ($this->multiple_value_separator != ',') {
                if (is_array($product->meta_keywords)) {
                    foreach ($product->meta_keywords as &$meta_keyword) {
                        if (!empty($meta_keyword)) {
                            $meta_keyword = str_replace($this->multiple_value_separator, ',', $meta_keyword);
                        }
                    }
                }
            }
            foreach (Product::$definition['fields'] as $key => $array) {
                if ($array['type'] == Product::TYPE_FLOAT) {
                    $product->{$key} = str_replace(',', '.', $product->{$key});
                }
            }
            $product->indexed = 0;
            $res = false;
            $field_error = $product->validateFields(UNFRIENDLY_ERROR, true);
            $lang_field_error = $product->validateFieldsLang(UNFRIENDLY_ERROR, true);
            if ($field_error === true && $lang_field_error === true) {
                if ($product->quantity == null) {
                    $product->quantity = 0;
                }
                if (Tools::getValue('match_ref') && $product->reference && $product->existsRefInDatabase($product->reference)) {
                    $datas = Db::getInstance()->getRow('
						SELECT product_shop.`date_add`, p.`id_product`
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE p.`reference` = "' . pSQL($product->reference) . '"
					');
                    $product->id = (int) $datas['id_product'];
                    $product->date_add = pSQL($datas['date_add']);
                    $res = $product->update();
                } elseif ($product->id && Product::existsInDatabase((int) $product->id, 'product')) {
                    $datas = Db::getInstance()->getRow('
						SELECT product_shop.`date_add`
						FROM `' . _DB_PREFIX_ . 'product` p
						' . Shop::addSqlAssociation('product', 'p') . '
						WHERE p.`id_product` = ' . (int) $product->id);
                    $product->date_add = pSQL($datas['date_add']);
                    $res = $product->update();
                }
                $product->force_id = (bool) Tools::getValue('forceIDs');
                if (!$res) {
                    if (isset($product->date_add) && $product->date_add != '') {
                        $res = $product->add(false);
                    } else {
                        $res = $product->add();
                    }
                }
                if ($product->getType() == Product::PTYPE_VIRTUAL) {
                    StockAvailable::setProductOutOfStock((int) $product->id, 1);
                } else {
                    StockAvailable::setProductOutOfStock((int) $product->id, (int) $product->out_of_stock);
                }
            }
            $shops = array();
            $product_shop = explode($this->multiple_value_separator, $product->shop);
            foreach ($product_shop as $shop) {
                if (empty($shop)) {
                    continue;
                }
                $shop = trim($shop);
                if (!empty($shop) && !is_numeric($shop)) {
                    $shop = Shop::getIdByName($shop);
                }
                if (in_array($shop, $shop_ids)) {
                    $shops[] = $shop;
                } else {
                    $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Shop is not valid'));
                }
            }
            if (empty($shops)) {
                $shops = Shop::getContextListShopID();
            }
            if (!$res) {
                $this->errors[] = sprintf(Tools::displayError('%1$s (ID: %2$s) cannot be saved'), isset($info['name']) && !empty($info['name']) ? Tools::safeOutput($info['name']) : 'No Name', isset($info['id']) && !empty($info['id']) ? Tools::safeOutput($info['id']) : 'No ID');
                $this->errors[] = ($field_error !== true ? $field_error : '') . (isset($lang_field_error) && $lang_field_error !== true ? $lang_field_error : '') . Db::getInstance()->getMsgError();
            } else {
                if (isset($product->id) && $product->id && isset($product->id_supplier) && property_exists($product, 'supplier_reference')) {
                    $id_product_supplier = (int) ProductSupplier::getIdByProductAndSupplier((int) $product->id, 0, (int) $product->id_supplier);
                    if ($id_product_supplier) {
                        $product_supplier = new ProductSupplier($id_product_supplier);
                    } else {
                        $product_supplier = new ProductSupplier();
                    }
                    $product_supplier->id_product = (int) $product->id;
                    $product_supplier->id_product_attribute = 0;
                    $product_supplier->id_supplier = (int) $product->id_supplier;
                    $product_supplier->product_supplier_price_te = $product->wholesale_price;
                    $product_supplier->product_supplier_reference = $product->supplier_reference;
                    $product_supplier->save();
                }
                if (!Shop::isFeatureActive()) {
                    $info['shop'] = 1;
                } elseif (!isset($info['shop']) || empty($info['shop'])) {
                    $info['shop'] = implode($this->multiple_value_separator, Shop::getContextListShopID());
                }
                $info['shop'] = explode($this->multiple_value_separator, $info['shop']);
                $id_shop_list = array();
                foreach ($info['shop'] as $shop) {
                    if (!empty($shop) && !is_numeric($shop)) {
                        $id_shop_list[] = (int) Shop::getIdByName($shop);
                    } elseif (!empty($shop)) {
                        $id_shop_list[] = $shop;
                    }
                }
                if (isset($info['reduction_price']) && $info['reduction_price'] > 0 || isset($info['reduction_percent']) && $info['reduction_percent'] > 0) {
                    foreach ($id_shop_list as $id_shop) {
                        $specific_price = SpecificPrice::getSpecificPrice($product->id, $id_shop, 0, 0, 0, 1, 0, 0, 0, 0);
                        if (is_array($specific_price) && isset($specific_price['id_specific_price'])) {
                            $specific_price = new SpecificPrice((int) $specific_price['id_specific_price']);
                        } else {
                            $specific_price = new SpecificPrice();
                        }
                        $specific_price->id_product = (int) $product->id;
                        $specific_price->id_specific_price_rule = 0;
                        $specific_price->id_shop = $id_shop;
                        $specific_price->id_currency = 0;
                        $specific_price->id_country = 0;
                        $specific_price->id_group = 0;
                        $specific_price->price = -1;
                        $specific_price->id_customer = 0;
                        $specific_price->from_quantity = 1;
                        $specific_price->reduction = isset($info['reduction_price']) && $info['reduction_price'] ? $info['reduction_price'] : $info['reduction_percent'] / 100;
                        $specific_price->reduction_type = isset($info['reduction_price']) && $info['reduction_price'] ? 'amount' : 'percentage';
                        $specific_price->from = isset($info['reduction_from']) && Validate::isDate($info['reduction_from']) ? $info['reduction_from'] : '0000-00-00 00:00:00';
                        $specific_price->to = isset($info['reduction_to']) && Validate::isDate($info['reduction_to']) ? $info['reduction_to'] : '0000-00-00 00:00:00';
                        if (!$specific_price->save()) {
                            $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Discount is invalid'));
                        }
                    }
                }
                if (isset($product->tags) && !empty($product->tags)) {
                    if (isset($product->id) && $product->id) {
                        $tags = Tag::getProductTags($product->id);
                        if (is_array($tags) && count($tags)) {
                            if (!empty($product->tags)) {
                                $product->tags = explode($this->multiple_value_separator, $product->tags);
                            }
                            if (is_array($product->tags) && count($product->tags)) {
                                foreach ($product->tags as $key => $tag) {
                                    if (!empty($tag)) {
                                        $product->tags[$key] = trim($tag);
                                    }
                                }
                                $tags[$id_lang] = $product->tags;
                                $product->tags = $tags;
                            }
                        }
                    }
                    Tag::deleteTagsForProduct($product->id);
                    if (!is_array($product->tags) && !empty($product->tags)) {
                        $product->tags = AdminImportController::createMultiLangField($product->tags);
                        foreach ($product->tags as $key => $tags) {
                            $is_tag_added = Tag::addTags($key, $product->id, $tags, $this->multiple_value_separator);
                            if (!$is_tag_added) {
                                $this->addProductWarning(Tools::safeOutput($info['name']), $product->id, $this->l('Tags list is invalid'));
                                break;
                            }
                        }
                    } else {
                        foreach ($product->tags as $key => $tags) {
                            $str = '';
                            foreach ($tags as $one_tag) {
                                $str .= $one_tag . $this->multiple_value_separator;
                            }
                            $str = rtrim($str, $this->multiple_value_separator);
                            $is_tag_added = Tag::addTags($key, $product->id, $str, $this->multiple_value_separator);
                            if (!$is_tag_added) {
                                $this->addProductWarning(Tools::safeOutput($info['name']), (int) $product->id, 'Invalid tag(s) (' . $str . ')');
                                break;
                            }
                        }
                    }
                }
                if (isset($product->delete_existing_images)) {
                    if ((bool) $product->delete_existing_images) {
                        $product->deleteImages();
                    }
                }
                if (isset($product->image) && is_array($product->image) && count($product->image)) {
                    $product_has_images = (bool) Image::getImages($this->context->language->id, (int) $product->id);
                    foreach ($product->image as $key => $url) {
                        $url = trim($url);
                        $error = false;
                        if (!empty($url)) {
                            $url = str_replace(' ', '%20', $url);
                            $image = new Image();
                            $image->id_product = (int) $product->id;
                            $image->position = Image::getHighestPosition($product->id) + 1;
                            $image->cover = !$key && !$product_has_images ? true : false;
                            if (($field_error = $image->validateFields(UNFRIENDLY_ERROR, true)) === true && ($lang_field_error = $image->validateFieldsLang(UNFRIENDLY_ERROR, true)) === true && $image->add()) {
                                $image->associateTo($shops);
                                if (!AdminImportController::copyImg($product->id, $image->id, $url, 'products', !Tools::getValue('regenerate'))) {
                                    $image->delete();
                                    $this->warnings[] = sprintf(Tools::displayError('Error copying image: %s'), $url);
                                }
                            } else {
                                $error = true;
                            }
                        } else {
                            $error = true;
                        }
                        if ($error) {
                            $this->warnings[] = sprintf(Tools::displayError('Product #%1$d: the picture (%2$s) cannot be saved.'), $image->id_product, $url);
                        }
                    }
                }
                if (isset($product->id_category) && is_array($product->id_category)) {
                    $product->updateCategories(array_map('intval', $product->id_category));
                }
                $product->checkDefaultAttributes();
                if (!$product->cache_default_attribute) {
                    Product::updateDefaultAttribute($product->id);
                }
                $features = get_object_vars($product);
                if (isset($features['features']) && !empty($features['features'])) {
                    foreach (explode($this->multiple_value_separator, $features['features']) as $single_feature) {
                        if (empty($single_feature)) {
                            continue;
                        }
                        $tab_feature = explode(':', $single_feature);
                        $feature_name = isset($tab_feature[0]) ? trim($tab_feature[0]) : '';
                        $feature_value = isset($tab_feature[1]) ? trim($tab_feature[1]) : '';
                        $position = isset($tab_feature[2]) ? (int) $tab_feature[2] - 1 : false;
                        $custom = isset($tab_feature[3]) ? (int) $tab_feature[3] : false;
                        if (!empty($feature_name) && !empty($feature_value)) {
                            $id_feature = (int) Feature::addFeatureImport($feature_name, $position);
                            $id_product = null;
                            if (Tools::getValue('forceIDs') || Tools::getValue('match_ref')) {
                                $id_product = (int) $product->id;
                            }
                            $id_feature_value = (int) FeatureValue::addFeatureValueImport($id_feature, $feature_value, $id_product, $id_lang, $custom);
                            Product::addFeatureProductImport($product->id, $id_feature, $id_feature_value);
                        }
                    }
                }
                Feature::cleanPositions();
                if (isset($product->advanced_stock_management)) {
                    if ($product->advanced_stock_management != 1 && $product->advanced_stock_management != 0) {
                        $this->warnings[] = sprintf(Tools::displayError('Advanced stock management has incorrect value. Not set for product %1$s '), $product->name[$default_language_id]);
                    } elseif (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $product->advanced_stock_management == 1) {
                        $this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, cannot enable on product %1$s '), $product->name[$default_language_id]);
                    } else {
                        $product->setAdvancedStockManagement($product->advanced_stock_management);
                    }
                    if (StockAvailable::dependsOnStock($product->id) == 1 && $product->advanced_stock_management == 0) {
                        StockAvailable::setProductDependsOnStock($product->id, 0);
                    }
                }
                if (isset($product->warehouse) && $product->warehouse) {
                    if (!Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {
                        $this->warnings[] = sprintf(Tools::displayError('Advanced stock management is not enabled, warehouse not set on product %1$s '), $product->name[$default_language_id]);
                    } else {
                        if (Warehouse::exists($product->warehouse)) {
                            $associated_warehouses_collection = WarehouseProductLocation::getCollection($product->id);
                            foreach ($associated_warehouses_collection as $awc) {
                                $awc->delete();
                            }
                            $warehouse_location_entity = new WarehouseProductLocation();
                            $warehouse_location_entity->id_product = $product->id;
                            $warehouse_location_entity->id_product_attribute = 0;
                            $warehouse_location_entity->id_warehouse = $product->warehouse;
                            if (WarehouseProductLocation::getProductLocation($product->id, 0, $product->warehouse) !== false) {
                                $warehouse_location_entity->update();
                            } else {
                                $warehouse_location_entity->save();
                            }
                            StockAvailable::synchronize($product->id);
                        } else {
                            $this->warnings[] = sprintf(Tools::displayError('Warehouse did not exist, cannot set on product %1$s.'), $product->name[$default_language_id]);
                        }
                    }
                }
                if (isset($product->depends_on_stock)) {
                    if ($product->depends_on_stock != 0 && $product->depends_on_stock != 1) {
                        $this->warnings[] = sprintf(Tools::displayError('Incorrect value for "depends on stock" for product %1$s '), $product->name[$default_language_id]);
                    } elseif ((!$product->advanced_stock_management || $product->advanced_stock_management == 0) && $product->depends_on_stock == 1) {
                        $this->warnings[] = sprintf(Tools::displayError('Advanced stock management not enabled, cannot set "depends on stock" for product %1$s '), $product->name[$default_language_id]);
                    } else {
                        StockAvailable::setProductDependsOnStock($product->id, $product->depends_on_stock);
                    }
                    if (isset($product->quantity) && $product->quantity) {
                        if ($product->depends_on_stock == 1) {
                            $stock_manager = StockManagerFactory::getManager();
                            $price = str_replace(',', '.', $product->wholesale_price);
                            if ($price == 0) {
                                $price = 1.0E-6;
                            }
                            $price = round((double) $price, 6);
                            $warehouse = new Warehouse($product->warehouse);
                            if ($stock_manager->addProduct((int) $product->id, 0, $warehouse, $product->quantity, 1, $price, true)) {
                                StockAvailable::synchronize((int) $product->id);
                            }
                        } else {
                            if (Shop::isFeatureActive()) {
                                foreach ($shops as $shop) {
                                    StockAvailable::setQuantity((int) $product->id, 0, $product->quantity, (int) $shop);
                                }
                            } else {
                                StockAvailable::setQuantity((int) $product->id, 0, $product->quantity, (int) $this->context->shop->id);
                            }
                        }
                    }
                } else {
                    if (Shop::isFeatureActive()) {
                        foreach ($shops as $shop) {
                            StockAvailable::setQuantity((int) $product->id, 0, $product->quantity, (int) $shop);
                        }
                    } else {
                        StockAvailable::setQuantity((int) $product->id, 0, $product->quantity, (int) $this->context->shop->id);
                    }
                }
            }
        }
        $this->closeCsvFile($handle);
    }
 /**
  * @param \Product $product
  * @param bool $ids
  *
  * @return string
  * @throws \Exception
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 150213
  */
 protected function getProductCategories(\Product &$product, $ids = false)
 {
     $maxDepth = 3;
     // TODO Implement in options or remove
     $categories = array();
     if ($this->Options->getValue('map_category') == 1) {
         $info = \Tag::getProductTags($product->id);
         if ($info && !isset($info[$this->defaultLang])) {
             $categories = (array) $info[$this->defaultLang];
         }
     } else {
         $defaultCat = $product->getDefaultCategory();
         if ($ids) {
             return $defaultCat;
         }
         $category = new \Category($defaultCat);
         do {
             array_push($categories, $ids ? $category->id : $category->name[$this->defaultLang]);
             $category = new \Category($category->id_parent);
         } while ($category->id_parent && !$category->is_root_category);
         $categories = array_reverse($categories);
     }
     return is_array($categories) ? implode($ids ? ' - ' : '->', $categories) : $categories;
 }
示例#14
0
 public function initFormInformations($product)
 {
     if (!$this->default_form_language) {
         $this->getLanguages();
     }
     $data = $this->createTemplate($this->tpl_form);
     $currency = $this->context->currency;
     $data->assign('languages', $this->_languages);
     $data->assign('default_form_language', $this->default_form_language);
     $data->assign('currency', $currency);
     $this->object = $product;
     //$this->display = 'edit';
     $data->assign('product_name_redirected', Product::getProductName((int) $product->id_product_redirected, null, (int) $this->context->language->id));
     /*
      * Form for adding a virtual product like software, mp3, etc...
      */
     $product_download = new ProductDownload();
     if ($id_product_download = $product_download->getIdFromIdProduct($this->getFieldValue($product, 'id'))) {
         $product_download = new ProductDownload($id_product_download);
     }
     $product->{'productDownload'} = $product_download;
     $cache_default_attribute = (int) $this->getFieldValue($product, 'cache_default_attribute');
     $product_props = array();
     // global informations
     array_push($product_props, 'reference', 'ean13', 'upc', 'available_for_order', 'show_price', 'online_only', 'id_manufacturer');
     // specific / detailled information
     array_push($product_props, 'width', 'height', 'weight', 'active', 'is_virtual', 'cache_default_attribute', 'uploadable_files', 'text_fields');
     // prices
     array_push($product_props, 'price', 'wholesale_price', 'id_tax_rules_group', 'unit_price_ratio', 'on_sale', 'unity', 'minimum_quantity', 'additional_shipping_cost', 'available_now', 'available_later', 'available_date');
     if (Configuration::get('PS_USE_ECOTAX')) {
         array_push($product_props, 'ecotax');
     }
     foreach ($product_props as $prop) {
         $product->{$prop} = $this->getFieldValue($product, $prop);
     }
     $product->name['class'] = 'updateCurrentText';
     if (!$product->id || Configuration::get('PS_FORCE_FRIENDLY_PRODUCT')) {
         $product->name['class'] .= ' copy2friendlyUrl';
     }
     $images = Image::getImages($this->context->language->id, $product->id);
     if (is_array($images)) {
         foreach ($images as $k => $image) {
             $images[$k]['src'] = $this->context->link->getImageLink($product->link_rewrite[$this->context->language->id], $product->id . '-' . $image['id_image'], 'small_default');
         }
         $data->assign('images', $images);
     }
     $data->assign('imagesTypes', ImageType::getImagesTypes('products'));
     $product->tags = Tag::getProductTags($product->id);
     $data->assign('product_type', (int) Tools::getValue('type_product', $product->getType()));
     $data->assign('is_in_pack', (int) Pack::isPacked($product->id));
     $check_product_association_ajax = false;
     if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_ALL) {
         $check_product_association_ajax = true;
     }
     // TinyMCE
     $iso_tiny_mce = $this->context->language->iso_code;
     $iso_tiny_mce = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso_tiny_mce . '.js') ? $iso_tiny_mce : 'en';
     $data->assign('ad', dirname($_SERVER['PHP_SELF']));
     $data->assign('iso_tiny_mce', $iso_tiny_mce);
     $data->assign('check_product_association_ajax', $check_product_association_ajax);
     $data->assign('id_lang', $this->context->language->id);
     $data->assign('product', $product);
     $data->assign('token', $this->token);
     $data->assign('currency', $currency);
     $data->assign($this->tpl_form_vars);
     $data->assign('link', $this->context->link);
     $data->assign('PS_PRODUCT_SHORT_DESC_LIMIT', Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') ? Configuration::get('PS_PRODUCT_SHORT_DESC_LIMIT') : 400);
     $this->tpl_form_vars['product'] = $product;
     $this->tpl_form_vars['custom_form'] = $data->fetch();
 }
示例#15
0
 public function __construct($id_product = NULL, $full = false, $id_lang = NULL)
 {
     global $cart;
     parent::__construct($id_product, $id_lang);
     if ($full and $this->id) {
         $this->tax_name = 'deprecated';
         // The applicable tax may be BOTH the product one AND the state one (moreover this variable is some deadcode)
         $this->manufacturer_name = Manufacturer::getNameById(intval($this->id_manufacturer));
         $this->supplier_name = Supplier::getNameById(intval($this->id_supplier));
         $tax = new Tax(intval($this->id_tax));
         if (is_object($cart) and $cart->id_address_delivery != NULL) {
             $this->tax_rate = Tax::getApplicableTax(intval($this->id_tax), floatval($tax->rate));
         } else {
             $this->tax_rate = floatval($tax->rate);
         }
         $this->new = $this->isNew();
     }
     if ($this->id_category_default) {
         $this->category = Category::getLinkRewrite(intval($this->id_category_default), intval($id_lang));
     }
     if ($this->id) {
         $this->tags = Tag::getProductTags(intval($this->id));
     }
 }
 /**
  * @param \Product $product
  *
  * @return string
  * @throws \Exception
  * @author Panagiotis Vagenas <*****@*****.**>
  * @since 150213
  */
 protected function getProductCategories(\Product &$product)
 {
     $categories = array();
     if ($this->Options->getValue('map_category') == 1) {
         $info = \Tag::getProductTags($product->id);
         if ($info && !isset($info[$this->defaultLang])) {
             $categories = (array) $info[$this->defaultLang];
         }
     } else {
         $info = \Category::getCategoryInformations($product->getCategories());
         if (!is_array($info) || empty($info)) {
             return '';
         }
         foreach ((array) $info as $cat) {
             // Todo is there a better way to check for home category?
             if ($cat['id_category'] == 2) {
                 continue;
             }
             array_push($categories, $cat['name']);
         }
     }
     return implode(' - ', (array) $categories);
 }
示例#17
0
 public function __construct($id_product = NULL, $full = false, $id_lang = NULL)
 {
     parent::__construct($id_product, $id_lang);
     if ($full and $this->id) {
         $this->manufacturer_name = Manufacturer::getNameById(intval($this->id_manufacturer));
         $this->supplier_name = Supplier::getNameById(intval($this->id_supplier));
         if (!class_exists("Vendor", false)) {
             include_once dirname(__FILE__) . '/../modules/ordervendor/Vendor.php';
         }
         $this->vendor_name = Vendor::getNameById(intval($this->id_vendor));
     }
     $this->category = Category::getLinkRewrite(intval($this->id_category_default), intval($id_lang));
     $this->tags = Tag::getProductTags($this->id);
 }