Hello I am using menu for mobile for prestashop 1.6 website.
I want to shange displayed name of categories.
I created name2 field for ps_category_lang table and filled with shorter category names. I want to show short names af mobile menu.
{foreach $subcategories as $subcategory}
{if ($subcategory->id|escape:'htmlall':'UTF-8') ne '45'}
<li {if count($subcategory->getChildrenWs())}class="icon-arrow"{/if}>
<a
class="rm-level__item rm-category-{$subcategory->id|intval}"
{if $subcategory->nright > $subcategory->nleft +1}data-load="{$subcategory->id|escape:'htmlall':'UTF-8'}"{/if}
href="{$subcategory->getLink()|escape:'htmlall':'UTF-8'}"
>{$subcategory->name|escape:'htmlall':'UTF-8'}</a>
</li>
{/if}
when I change $subcategory->name to $subcategory->name2 menu shows empty category names.
https://addons.prestashop.com/en/mobile/17310-menu-for-mobile.html
where this subcategories created?
You also have to modify (preferably and most recommended, override) the Category.php (in classes) class and add the field name2 in the Lang fields definition of the model.
Related
I am trying to display a dropdown with all the countries that prestashop has in his database.
When a customer is adding a new address, a field ask for the country, but displays only United States.
How can I make to display all the countries?
Because when I edit the customer I can see all the countries.
What I have tried:
In the location: /public_html/Project/themes/myTemplate/templates/_partials/form-fields.tpl
I realized there is a Foreach to fill the dropdown, but load United States.
{elseif $field.type === 'countrySelect'}
{block name='form_field_item_country'}
<select
class="custom-select js-country"
name="{$field.name}"
{if $field.required}required{/if}
>
<option value disabled selected>{$field.label}</option>
{foreach from=$field.availableValues item="label" key="value"}
<option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
{/foreach}
</select>
{/block}
I can see in console, actually, loads one value only.
Could anybody has the same error?
How can you help me to fix it?
Go in International > Locations , check Countries tab and make sure the other countries are active (they aren't in a standard US / UK Prestashop installation)
I am using Prestashop 1.7 and I want to check if a product is in a specific category and change the image on the product.tpl
{if $product->id_category_default == 10}
is not working.
In the field $product->id_category_default stored a value only main (~first) category id. If your product is in a few categories, relations stored in table category_product. You can access to array of all categories of a product by using $product->getWsCategories(). You can see it like this:
{$product->getWsCategories()|var_dump}
As you want to check if product is in a special category, you should do like this:
{foreach from=$product->getWsCategories() key='k' item='category'}
{if $category.id == 7760}
here you insert something
{/if}
{/foreach}
Edited:
Previous method works well in Prestashop 1.4, but developers modified $product object to array, so you cannot run object functions anymore.
I found a solution for 1.7 version. See:
{foreach from=Product::getProductCategoriesFull(Tools::getValue('id_product')) item=category}
{$category|var_dump}
{if $category.id_category== '1041'}
// here you can insert img
{/if}
{/foreach}
It works by similar way.
Each product has the custom fields options. Can I output those custom fields on each product item in the product list page? If so, how? I have tried adding the ProductOtherDetails and the %%SNIPPET_ProductCustomFieldItem%% in the CategoryProductsItem.html, but got no output at all of any of the items I have tried. Any suggestions or pointers on how and if this is possible?
As of September 2015, you can now access %%GLOBAL_ProductCustomFields%% on any template file that renders a particular panel's individual items. For example:
-Snippets/CategoryProductsItem.html for category list pages
-Snippets/HomeFeaturedProductsItem.html for the featured products panel
I recommend adding the custom field name as a class to each field for easy hiding, and accessing of the value in case the custom fields ever change you won't be accessing them via :nth-child CSS which would break. You can do so by modify Snippets/ProductCustomFieldItem.html to add the custom field name to the CSS class or ID like this:
<div class="DetailRow %%GLOBAL_CustomFieldName%%">
<div class="Label">%%GLOBAL_CustomFieldName%%:</div>
<div class="Value">
%%GLOBAL_CustomFieldValue%%
</div>
</div>
Doing so, will output like this in each item in the category list.
Above, I am using the custom fields to send through shipping time, as well as "Starting At" to prepend to the list page price if the item is a parent which has children of higher prices. In my opinion, these features greatly increase the user experience.
For Faceted Search (handlebars.js)
I recommend adding this to Panels/FacetedSearchProductGrid.html:
{{#each product.custom_fields}}
{{ id }} : {{ name }} : {{ value }}
{{/each}}
Those filters will be limited to the Product pages specifically. The only way around it is to hash together a solution using jQuery to go and fetch items in question from the product page. A pain, but do-able with unnecessary effort.
I have a problem regarding a webpage that I´m currently working on.
The theme that I´m working the site with is gameguru 1.5 and the matter is that on the final row of my product-list, when I get to the bottom of it, there are 2 products appearing instead of 3.
The relevant code of the source file (product-list.tpl) is this one:
{if isset($products)}
<!-- Products list -->
<div id="product_list" class="clear category_list product_list grid row">
<div class="inner-product-list">
{foreach from=$products item=product name=products}
<div class="ajax_block_product {if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if} {if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix col-xs-6 col-sm-6 col-md-4">
I´ve tried several things but I´m quite stuck here.
Finally, I would like to include one product list of the webpage in order to give you a bit more guidance.
http://tutiendadevideojuegos.com/127-ps4-videojuegos-ps4
I would appreciate very much any help.
Thanks,
Orestis
try this part
{if $smarty.foreach.products.index % 2}alternate_item{else}item{/if}
change to
{if $smarty.foreach.products.index % 3}alternate_item{else}item{/if}
UPD:
to manipulate number of products per page, in backoffice Preferences -> Products option "Products per page" put there e.g. 12 and you will have 3 products in all lines + correct values in dropdown.
I want to make a button with a modal effect on product page with ex. size table. I want to show only this size table depending on acutal product manufacturer.
Ex. Nike shoes
On product page (product.tpl file) button named like "size table". After use the button the modal popup box will show only the Nike shoe size table.
Maybe something like this should work?
{if $manufacutrer_name !='Nike'}
Size table
{/if}
Use the manufacturer id, you can do:
{if $product->id_manufacturer == 23}
Size table
{/if}