How can i get catecory name and link inside the products list in Prestashop 1.7 using smarty code? - smarty

I am building a new theme and i am looking for a way to display the category name and the category link inside each product item in product lists. I am using the smarty code
{$product.category_name}
so i can get the category name of the product that belongs to that category but i really can't find a way (using smarty code) so i can get the url that links to that category. I already tried:
{$product.category_name}
but this code generate the url:
http://mysite/home-accessories
instead of:
Quote
http://mysite/8-home-accessories
Does anyone knows how can i make it work using only smarty code ?

In prestashop 1.7, the is a smarty utility called url that acts as the prestashop 1.7 equivalent of the prestashop 1.6 $link object. The use is as follows:
Prestashop 1.6 : {$link->getCategoryLink(params here)}
Prestashop 1.7 : {url entity='category' id=(your product category id you can get from the $product object) id_lang=$id_lang}
Example : {url entity='category' id=$product.id_category_default id_lang=2}
There are additional configurations to this function that are explained further in the documentation.

{$product.id}-$product.category_name}

Related

Get the id of last product image to show it as a background on frontend - Prestashop 1.7.6

Do you know if it's possible to retrieve the id of last image added on backend product page (see attachment: https://i.stack.imgur.com/Ks9Xm.jpg) to show it on frontend?
I done it on prestashop 1.6 like this -> {$link->getImageLink($product->link_rewrite, $imageIds, 'new_img_details')|escape:'html':'UTF-8'}
but I don't know how to do it on prestashop 1.7.6
thank you
You can get the id_image in last position with a query in your PHP module / controller :
$lastIdImage = Db::getInstance()->getValue('SELECT id_image FROM '._DB_PREFIX_.'image
WHERE id_product = '.$your_id_product.' ORDER BY position DESC');
Then you can easily retrieve the link with the getImageLink method.

Prestashop 1.6 default theme price

In prestashop 1.6 default theme i would like to change the price like on the photo. I tired the product.tpl file but its not working. I dont know why but i can not finde it the main file where i can modify the template. Is there any solution for this problem ? i should put simply just a br tag but i dont know what file should i use.
photo
There has to be someone who know it. Should i try an another file ? or can i do it in the css ?
If you're using default-bootstrap theme you should look into themes/default-bootstrap/product-list.tpl
after changes remember about clearing the cache in Adv. Preferences -> Performance
Two files shows products prices : product.tpl and product-list.tpl :
product-list.tpl is your product list on category page.
product.tpl shows only one product (product page)
You also have in themes/default-bootstrap/css files, like product.css and product-list.css
Before working on it (and as Krystian said), desactivate cache.
Prices have HTML useful classes in Prestashop :
.price
.product-price
This would help finding correct lines in template files.

Virtuemart displaying

I want to know if someone know how to display a virtuemart category products into another page like use a shortcode or something like that to display a list of product from one category into another page.
Thanks for your help.
You could do that with a module.
The default "virtuemart products" module has an option to select from which category you will get the products.
If you want to put them inside an article, you could load your module with loadposition. A complete tutorial how you could do that is: How do you put a module inside an article?

Magento Layered Navigation - Category links

I have this site on magento, wherein on category pages there is browse by category filter in the left.
But the issue is the links are like www.domain.com/main-cat/?cat=32 because of which, the products sure gets pulled but the category description and image remains the same as that of the main category.
is there any way to convert these dynamic urls to /main-cat/sub-cat ?
magento varsion 1.4.2
Thanks & Regards,
Sushil

Filter one specific attribute values from products in magento

I'm new in magento, I'm working on http://www.theartworkgallery24.com/stage/ website. Please check beneath flash banner, there are 4 big images that are links to attributes value from which user can directly go to a product.
I need a page that display on one specific attribute values like in case of artist, it should be Gustav Klimt, Leonardo Da Vinci etc. These should be links to actual product related to the attribute values.
Please tell me how to make your own PHTML or PHP file, which code to use and how, and in last how to call your code in your magento website.
Any ideas will be appreciated, thanks.
You please create an attribute (davinchi) in admin side for these functionality. You can create products attributes from catalog->attributes->menu.After that you can see these attribute value in product creation page.You just assign it to different products
After that you can either create a module for this. Otherwise just create a phtml file in catalog/product/ folder.
then enter the below custom collection code in it.
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
//filter codition
$collection->addFieldToFilter(array(
array('attribute'=>'davinchi','eq'=>1),
));
This will load products having attribute value davinchi=1.

Resources