public function initContent()
 {
     parent::initContent();
     $parent_cat = new CMSCategory(1, $this->context->language->id);
     $this->context->smarty->assign('id_current_lang', $this->context->language->id);
     $this->context->smarty->assign('home_title', $parent_cat->name);
     $this->context->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
     if (isset($this->cms->id_cms_category) && $this->cms->id_cms_category) {
         $path = Tools::getFullPath($this->cms->id_cms_category, $this->cms->meta_title, 'CMS');
     } else {
         if (isset($this->cms_category->meta_title)) {
             $path = Tools::getFullPath(1, $this->cms_category->meta_title, 'CMS');
         }
     }
     if ($this->assignCase == 1) {
         $this->context->smarty->assign(array('og_type' => 'article', 'cms' => $this->cms, 'content_only' => (int) Tools::getValue('content_only'), 'path' => $path, 'body_classes' => array($this->php_self . '-' . $this->cms->id, $this->php_self . '-' . $this->cms->link_rewrite)));
         if ($this->cms->indexation == 0) {
             $this->context->smarty->assign('nobots', true);
         }
     } else {
         if ($this->assignCase == 2) {
             $this->context->smarty->assign(array('category' => $this->cms_category, 'cms_category' => $this->cms_category, 'sub_category' => $this->cms_category->getSubCategories($this->context->language->id), 'cms_pages' => CMS::getCMSPages($this->context->language->id, (int) $this->cms_category->id, true, (int) $this->context->shop->id), 'path' => $this->cms_category->id !== 1 ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : '', 'body_classes' => array($this->php_self . '-' . $this->cms_category->id, $this->php_self . '-' . $this->cms_category->link_rewrite)));
         }
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'cms.tpl');
 }
Example #2
0
 /**
  * @param Product $product to get the product properties
  * @param array $combination to get particular properties from a declination
  * @param int $lang id lang to take all text in good language
  * @param Link $link to set the link of the product and its images.
  * @param Carrier $carrier not used now, but usable for next version, needed for calculate the shipping cost,
  * 		  But for now it's not sure enough.
  * @return array with good value for the XML.
  */
 private function preparedValues(Product $product, $combination, $lang, Link $link, Carrier $carrier)
 {
     $arr_return = array();
     $str_features = array();
     $model = array();
     $version = str_replace('.', '', _PS_VERSION_);
     // To build description and model tags.
     if (isset($combination['attributes'])) {
         foreach ($combination['attributes'] as $attribut) {
             $str_features[] = $attribut['group_name'] . ' : ' . $attribut['name'];
             $model[] = $attribut['name'];
         }
     }
     if (isset($combination['weight']) && (int) $combination['weight'] !== 0) {
         $str_features[] = 'weight : ' . $combination['weight'];
     } elseif ($product->weight !== 0) {
         $str_features[] = 'weight : ' . $product->weight;
     }
     $features = $product->getFrontFeatures($lang);
     foreach ($features as $feature) {
         $str_features[] = $feature['name'] . ' : ' . $feature['value'];
     }
     // Category tag
     $category = new Category((int) $product->id_category_default, $lang);
     $category_path = (isset($category->id) and $category->id) ? Tools::getFullPath((int) $category->id, $product->name[$lang]) : Tools::getFullPath((int) $product->id_category_default, $product->name[$lang]);
     $category_path = Configuration::get('PS_NAVIGATION_PIPE') != false && Configuration::get('PS_NAVIGATION_PIPE') !== '>' ? str_replace(Configuration::get('PS_NAVIGATION_PIPE'), '>', $category_path) : $category_path;
     // image tag
     $id_image = isset($combination['id_image']) ? $combination['id_image'] : 0;
     if ($id_image === 0 || $id_image < 0) {
         $image = $product->getCover((int) $product->id);
         $id_image = $image['id_image'];
     }
     $quantity = Product::getQuantity($product->id, isset($combination['id_combination']) ? $combination['id_combination'] : NULL);
     $condition = '';
     if (strlen((string) $version) < 2) {
         $version = (string) $version . '0';
     }
     if ((int) substr($version, 0, 2) >= 14) {
         $condition = $product->condition === 'new' ? 0 : 1;
     }
     $price = $product->getPrice(true, isset($combination['id_combination']) ? $combination['id_combination'] : NULL, 2);
     $upc_ean = strlen((string) $product->ean13) == 13 ? $product->ean13 : '';
     $arr_return['product_url'] = $link->getProductLink((int) $product->id, $product->link_rewrite[$lang], $product->ean13, $lang);
     $arr_return['designation'] = Tools::htmlentitiesUTF8($product->name[$lang] . ' ' . Manufacturer::getNameById($product->id_manufacturer) . ' ' . implode(' ', $model));
     $arr_return['price'] = $price;
     $arr_return['category'] = Tools::htmlentitiesUTF8(strip_tags($category_path));
     if (substr(_PS_VERSION_, 0, 3) == '1.3') {
         if (!Configuration::get('PS_SHOP_DOMAIN')) {
             Configuration::updateValue('PS_SHOP_DOMAIN', $_SERVER['HTTP_HOST']);
         }
         $prefix = 'http://' . Configuration::get('PS_SHOP_DOMAIN') . '/';
         $arr_return['image_url'] = $prefix . $link->getImageLink('', $product->id . '-' . $id_image, 'large');
     } else {
         $arr_return['image_url'] = $link->getImageLink($product->link_rewrite[$lang], $product->id . '-' . $id_image, 'large');
     }
     // Must description added since Twenga-module v1.1
     $arr_return['description'] = is_array($product->description) ? strip_tags($product->description[$lang]) : strip_tags($product->description);
     $arr_return['description'] = trim($arr_return['description'] . ' ' . strip_tags(implode(', ', $str_features)));
     $arr_return['description'] = Tools::htmlentitiesUTF8($arr_return['description']);
     $arr_return['brand'] = Manufacturer::getNameById($product->id_manufacturer);
     $arr_return['merchant_id'] = $product->id;
     $arr_return['manufacturer_id'] = $product->id_manufacturer;
     $arr_return['shipping_cost'] = 'NC';
     $arr_return['in_stock'] = $quantity > 0 ? 'Y' : 'N';
     $arr_return['stock_detail'] = $quantity;
     $arr_return['condition'] = $condition;
     $arr_return['upc_ean'] = $upc_ean;
     $arr_return['eco_tax'] = $product->ecotax;
     // for prestashop 1.4 and previous version these fields are not managed.
     // So default values are set.
     $arr_return['product_type'] = '1';
     $arr_return['isbn'] = '';
     return $arr_return;
 }
Example #3
0
         if (Product::idIsOnCategoryId(intval($product->id), array('0' => array('id_category' => intval($regs[2]))))) {
             $category = new Category(intval($regs[2]), intval($cookie->id_lang));
         }
     } elseif (isset($regs[5]) and is_numeric($regs[5])) {
         if (Product::idIsOnCategoryId(intval($product->id), array('0' => array('id_category' => intval($regs[5]))))) {
             $category = new Category(intval($regs[5]), intval($cookie->id_lang));
         }
     }
 }
 if (!$category) {
     $category = new Category($product->id_category_default, intval($cookie->id_lang));
 }
 if (isset($category) and Validate::isLoadedObject($category)) {
     $smarty->assign(array('category' => $category, 'subCategories' => $category->getSubCategories(intval($cookie->id_lang), true), 'id_category_current' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name))));
 }
 $smarty->assign(array('return_link' => (isset($category->id) and $category->id) ? Tools::safeOutput($link->getCategoryLink($category)) : 'javascript: history.back();', 'path' => (isset($category->id) and $category->id) ? Tools::getFullPath(intval($category->id), $product->name) : Tools::getFullPath(intval($product->id_category_default), $product->name)));
 $lang = Configuration::get('PS_LANG_DEFAULT');
 if (Pack::isPack(intval($product->id), intval($lang)) and !Pack::isInStock(intval($product->id), intval($lang))) {
     $product->quantity = 0;
 }
 /* /Quantity discount management */
 $smarty->assign(array('quantity_discounts' => QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()), 'product' => $product, 'homeSize' => Image::getSize('home'), 'jqZoomEnabled' => $jqZoomEnabled, 'product_manufacturer' => new Manufacturer(intval($product->id_manufacturer)), 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => floatval($productPriceWithoutEcoTax), 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $product->isAvailableWhenOutOfStock(intval($product->out_of_stock)), 'last_qties' => intval($configs['PS_LAST_QTIES']), 'group_reduction' => (100 - Group::getReduction(intval($cookie->id_customer))) / 100, 'col_img_dir' => _PS_COL_IMG_DIR_, 'HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')));
 $images = $product->getImages(intval($cookie->id_lang));
 $productImages = array();
 foreach ($images as $k => $image) {
     if ($image['cover']) {
         $smarty->assign('mainImage', $images[0]);
         $cover = $image;
         $cover['id_image'] = intval($product->id) . '-' . $cover['id_image'];
         $cover['id_image_only'] = intval($image['id_image']);
     }
Example #4
0
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $parent_cat = new CMSCategory(1, $this->context->language->id);
     $this->context->smarty->assign('id_current_lang', $this->context->language->id);
     $this->context->smarty->assign('home_title', $parent_cat->name);
     $this->context->smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
     if (isset($this->cms->id_cms_category) && $this->cms->id_cms_category) {
         $path = Tools::getFullPath($this->cms->id_cms_category, $this->cms->meta_title, 'CMS');
     } else {
         $path = Tools::getFullPath(1, $this->cms_category->meta_title, 'CMS');
     }
     if ($this->assignCase == 1) {
         $this->context->smarty->assign(array('cms' => $this->cms, 'content_only' => (int) Tools::getValue('content_only'), 'path' => $path));
     } else {
         if ($this->assignCase == 2) {
             $this->context->smarty->assign(array('cms_category' => $this->cms_category, 'sub_category' => $this->cms_category->getSubCategories($this->context->language->id), 'cms_pages' => CMS::getCMSPages($this->context->language->id, (int) $this->cms_category->id), 'path' => $this->cms_category->id !== 1 ? Tools::getPath($this->cms_category->id, $this->cms_category->name, false, 'CMS') : ''));
         }
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'cms.tpl');
 }
 public function process()
 {
     parent::process();
     $parent_cat = new CMSCategory(1, (int) self::$cookie->id_lang);
     self::$smarty->assign('id_current_lang', self::$cookie->id_lang);
     self::$smarty->assign('home_title', $parent_cat->name);
     self::$smarty->assign('cgv_id', Configuration::get('PS_CONDITIONS_CMS_ID'));
     if ($this->assignCase == 1) {
         self::$smarty->assign(array('cms' => $this->cms, 'content_only' => (int) Tools::getValue('content_only'), 'path' => (isset($this->cms->id_cms_category) and $this->cms->id_cms_category) ? Tools::getFullPath((int) $this->cms->id_cms_category, $this->cms->meta_title, 'CMS') : Tools::getFullPath(1, $this->cms->meta_title, 'CMS')));
     } elseif ($this->assignCase == 2) {
         self::$smarty->assign(array('category' => $this->cms_category, 'sub_category' => $this->cms_category->getSubCategories((int) self::$cookie->id_lang), 'cms_pages' => CMS::getCMSPages((int) self::$cookie->id_lang, (int) $this->cms_category->id), 'path' => $this->cms_category->id !== 1 ? Tools::getPath((int) $this->cms_category->id, $this->cms_category->name, false, 'CMS') : ''));
     }
 }