display specific category in prestashop tab homepage - prestashop

I'd like to display in the new products tab in prestashop 1.6 homepage only products from a specific category
I use blocknewproducts_home.tpl
I tried this code below but nothing display from the category 114 (with get products attached)
{if $id_category == 114}
{include file="$tpl_dir./product-list.tpl" products=$new_products class='blocknewproducts tab-pane' id='blocknewproducts'}
{/if}
{if isset($new_products) && $new_products}
{include file="$tpl_dir./product-list.tpl" products=$new_products class='blocknewproducts tab-pane' id='blocknewproducts'}
{else}
<ul id="blocknewproducts" class="blocknewproducts tab-pane">
<li class="alert alert-info">{l s='No new products at this time.' mod='blocknewproducts'}</li>
</ul>
{/if}
Thanks for your help

try width : {if $smarty.get.id_category == 114}
Regards

Related

"---please make a choise---" prestashop form

i would like to make default "---please make a choice--'. Actually in checkout adress form state is compilate like italia. I put a screenenter image description here
You need to find block responsible for showing province field and add something like this right above foreach loop:
<option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
Example based on "Select a country" located in prestashop\themes\classic\templates_partials\form-fields.tpl:
{block name='form_field_item_country'}
<select
class="form-control form-control-select js-country"
name="{$field.name}"
{if $field.required}required{/if}
>
<option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
{foreach from=$field.availableValues item="label" key="value"}
<option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
{/foreach}
</select>
{/block}

own pages/templates don't genereate page_name

I am trying to add a breadcrumb entry to portal pages. I try to copy form the sale module. Inside this module there is this template that adds new breadcrumb entries:
<template id="portal_my_home_menu_sale" name="Portal layout : sales menu entries" inherit_id="portal.portal_breadcrumbs" priority="20">
<xpath expr="//ol[hasclass('o_portal_submenu')]" position="inside">
<li t-if="page_name == 'quote' or sale_order and sale_order.state in ('sent', 'cancel')" t-attf-class="breadcrumb-item #{'active ' if not sale_order else ''}">
<a t-if="sale_order" t-attf-href="/my/quotes?{{ keep_query() }}">Quotations</a>
<t t-else="">Quotations</t>
</li>
<li t-if="page_name == 'order' or sale_order and sale_order.state not in ('sent', 'cancel')" t-attf-class="breadcrumb-item #{'active ' if not sale_order else ''}">
<a t-if="sale_order" t-attf-href="/my/orders?{{ keep_query() }}">Sales Orders</a>
<t t-else="">Sales Orders</t>
</li>
<li t-if="sale_order" class="breadcrumb-item active">
<span t-field="sale_order.type_name"/>
<t t-esc="sale_order.name"/>
</li>
</xpath>
</template>
The templates I created don't have a page_name attribute. How can I add this to my templates?
Stock portal pages have home, order, or invoice as page_name but I couldn't find that in stock templates.
Variables settings are added either at the time of calling the render function or using t-set inside the template, or both.
On your particular case, page_name gets assigned inside portal_my_quotes (See <path_to_v12>/addons/sale/controllers/portal.py lines 39-90. See an excerpt below.) which is the controller for the route /my/quotes
#http.route(['/my/quotes', '/my/quotes/page/<int:page>'], type='http', auth="user", website=True)
def portal_my_quotes(self, page=1, date_begin=None, date_end=None, sortby=None, **kw):
values = self._prepare_portal_layout_values()
...
values.update({
'date': date_begin,
'quotations': quotations.sudo(),
'page_name': 'quote',
'pager': pager,
'archive_groups': archive_groups,
'default_url': '/my/quotes',
'searchbar_sortings': searchbar_sortings,
'sortby': sortby,
})
return request.render("sale.portal_my_quotations", values)
Documentation regarding the use of t-set can be found at https://www.odoo.com/documentation/12.0/reference/qweb.html#setting-variables

call function since product-variants.tpl Prestashop

I'm creating a web in Prestashop and my problem is the next:
I has created a new table in db (mysql) called 'tallas' and I have the size's preferences of the users. Now, I need call this table since the page product-variants.tpl because I would like to put cheeked for default the option select by the customer.
I create this function in classes/Product.php
public function getTalla($id_customer){
$result = Db::getInstance()->ExecuteS('
SELECT `talla1`
FROM `tallas`
WHERE `cliente` = `$id_customer`');
return $result;
}
ok, I would like to receive for parameters the user id (I don't know how to do that yet) and I would like to receive the value of talla1 and then I would like put cheeked the option selected by the customer here in the themes/asmart/templates/catalog/_partials/product-variants.tpl in the radio.
<li class="float-xs-left input-container">
<label>
<input class="input-color" type="radio" data-product-attribute="{$id_attribute_group}" name="group[{$id_attribute_group}]" value="{$id_attribute}"{if $group_attribute.selected} checked="checked"{/if}>
<span
{if $group_attribute.html_color_code}class="color" style="background-color: {$group_attribute.html_color_code}" {/if}
{if $group_attribute.texture}class="color texture" style="background-image: url({$group_attribute.texture})" {/if}
><span class="sr-only">{$group_attribute.name}</span></span>
</label>
</li>
Sincerely I don't know any idea to how to do that, can someone help me?
UPDATE: The problem is solved!
The problem is solved. I do that:
in classes/Product.php
public function getTalla(){
$variable = Context::getContext()->customer->id;
$result = Db::getInstance()->ExecuteS('SELECT * FROM `tallas` WHERE `cliente` = `$variable`');
return $result;
}
in ProductController.php
$this->context->smarty->assign('images_ex',$this->product->getTalla());
in product-variants.tpl
{if $images_ex[0]['talla1'] == $group_attribute.name} checked="checked"{/if}
I hope this can help someone in the future.

Prestashop - Show the prices are tax excluded for visitors

I am on Prestashop 1.6
When a user is a guest or a member, the mention "tax excl." is displayed next to the price in the products sheets.
Like this :
I would like this text to appear also for the visitors.
For visitors, it currently shoows like this :
So go to Client -> Group and for all groups choose as price display the HT.
Regards,
In Back office, customers > groups choose the visitor group click to modify button, change the tax display to tax incl, if it is like that, go to admin coutries choose your country, click to modify button and enable tax showing
think I found the solution. In product.tpl, replace
<span id="our_price_display" class="price" itemprop="price" content="{$productPrice}">{convertPrice price=$productPrice|floatval}</span>
{if $tax_enabled && ((isset($display_tax_label) && $display_tax_label == 1) || !isset($display_tax_label))}
{if $priceDisplay == 1} {l s='tax excl.'}{else} {l s='tax incl.'}{/if}
{ /if}
With :
<span id="our_price_display" class="price" itemprop="price" content="{$productPrice}">{convertPrice price=$productPrice|floatval}</span>
{if $priceDisplay == 1} {l s='tax excl.'}{else} {l s='tax incl.'}{/if}

add page number to meta title in category page on prestashop

i have category pages with a lot of products.
for example :
https://www.cdsoft.co.il/index.php?id_category=218&controller=category&id_lang=3&p=3
https://www.cdsoft.co.il/index.php?id_category=218&controller=category&id_lang=3&p=4
https://www.cdsoft.co.il/index.php?id_category=218&controller=category&id_lang=3&p=4
they all have the same meta title .
i want to add to each meta title the string " - page number XX"
HOW TO DO IT ?
I've found it :)
i'm using blocklayered module , and there is a function call Ajax call.
when i'm using blocklayered- the meta title comes from the ajax function :)
so - with the help of Yaniv Mirel - in line 3174 , on module/blocklayered/blocklayered.php - line 3174 :
'meta_title' => $meta_title . ' | ' . $this->l('page') . ' ' . $p . ' - ' . Configuration::get('PS_SHOP_NAME'),
This problem is caused by Block Layered module on PrestaShop 1.6. To solve this you should add rel "Prev" and "Next" page tags to your category pages with more than 1 page. Please find this file:
themes/[Your Theme]/header.tpl
and add the code bellow before </head> tag:
{if isset($p) AND $p}
{if $start!=$stop}
{if $p != 1}
{assign var='p_previous' value=$p-1}
<link rel="prev" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl|escape:'html':'UTF-8'}{else}{$base_dir|escape:'html':'UTF-8'}{/if}{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''|escape:'html':'UTF-8'}{$link->goPage($requestPage, $p_previous)|escape:'html':'UTF-8'}" />
{/if}
{if $pages_nb > 1 AND $p != $pages_nb}
{assign var='p_next' value=$p+1}
<link rel="next" href="{if isset($force_ssl) && $force_ssl}{$base_dir_ssl|escape:'html':'UTF-8'}{else}{$base_dir|escape:'html':'UTF-8'}{/if}{$request_uri|substr:1|regex_replace:'/\/(.*)/':''|regex_replace:'/\?(.*)/':''|escape:'html':'UTF-8'}{$link->goPage($requestPage, $p_next)|escape:'html':'UTF-8'}" />
{/if}
{/if}
{/if}
You can also use this module which solves the issue automatically:
https://addons.prestashop.com/en/seo-natural-search-engine-optimization/40888-seo-smo-assistant.html