refloblu Posted December 11, 2015 Share Posted December 11, 2015 hello guys,i need a little help, in my products page it shows "related products" but in the related products box it shows the oldest ones i added in the same category, how can i make appear the most recent instead of the oldest? i think the change should be made in productscategory.tpl {if count($categoryProducts) > 0 && $categoryProducts !== false} <div id="blockproductscategory" class="clearfix"> <h2 class="bordercolor">{$categoryProducts|@count} {l s='other products in the same category:' mod='productscategory'}</h2> <div id="{if count($categoryProducts) > 5}productscategory{else}productscategory_noscroll{/if}"> {if count($categoryProducts) > 5}<a id="productscategory_scroll_left" title="{l s='Previous' mod='productscategory'}" href="javascript:{ldelim}{rdelim}">{l s='Previous' mod='productscategory'}</a>{/if} <div id="productscategory_list"> <ul {if count($categoryProducts) > 5}style="width: {math equation="width * nbImages - 20" width=144 nbImages=$categoryProducts|@count}px"{/if}> {foreach from=$categoryProducts item='categoryProduct' name=categoryProduct} {if count($categoryProducts) < 6}style="width: {math equation="width / nbImages" width=94 nbImages=$categoryProducts|@count}%"{/if} <li class="bordercolor{if $smarty.foreach.categoryProduct.last} item_last{/if}"> <a href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" class="lnk_img" title="{$categoryProduct.name|htmlspecialchars}"><img class="bordercolor" src="{$link->getImageLink($categoryProduct.link_rewrite, $categoryProduct.id_image, 'medium_default')}" alt="{$categoryProduct.name|htmlspecialchars}" /></a> <h5><a class="product_link" href="{$link->getProductLink($categoryProduct.id_product, $categoryProduct.link_rewrite, $categoryProduct.category, $categoryProduct.ean13)}" title="{$categoryProduct.name|htmlspecialchars}">{$categoryProduct.name|truncate:0:'...'|escape:'htmlall':'UTF-8'}</a></h5> {if $ProdDisplayPrice AND $categoryProduct.show_price == 1 AND !isset($restricted_country_mode) AND !$PS_CATALOG_MODE} <p><span class="price pricecolor">{convertPrice price=$categoryProduct.displayed_price}</span></p> {/if} </li> {/foreach} </ul> </div> {if count($categoryProducts) > 5}<a id="productscategory_scroll_right" title="{l s='Next' mod='productscategory'}" href="javascript:{ldelim}{rdelim}">{l s='Next' mod='productscategory'}</a>{/if} </div> <script type="text/javascript"> $('#productscategory_list').trigger('goto', [{$middlePosition}-3]); </script> </div> {/if} can someone help me with what change the code to? Link to comment Share on other sites More sharing options...
Bill Dalton Posted December 11, 2015 Share Posted December 11, 2015 You do this in BO. Preferences > Products > Pagination Set it any way you like. Link to comment Share on other sites More sharing options...
refloblu Posted December 11, 2015 Author Share Posted December 11, 2015 in that page it doesnt let me manage the "related products" space in the product page, just the pagination of the the categories.. Link to comment Share on other sites More sharing options...
Bill Dalton Posted December 12, 2015 Share Posted December 12, 2015 I'm sorry, I didn't read your post clearly. Are you asking about the "related products" that appear on a product page? You seem to be asking about category pages. Link to comment Share on other sites More sharing options...
refloblu Posted December 12, 2015 Author Share Posted December 12, 2015 exactly, i would like the "related products" in the product page to show the last added products in the category, right now is showing the oldest one.. Link to comment Share on other sites More sharing options...
Bill Dalton Posted December 12, 2015 Share Posted December 12, 2015 Here is an old solution applied in ver 1.4 of Prestashop, https://www.prestashop.com/forums/topic/89260-accessories-on-producttpl-sorted-by-price/ I took a look at the code in, classes/product.php and it is the same, so it looks like you could give it a try. I do hope you have made a copy of your web site to experiment with. Link to comment Share on other sites More sharing options...
Bill Dalton Posted December 12, 2015 Share Posted December 12, 2015 BTW, I don't know what your time is worth, but for me, I usually look for a module. For exsample, I don't know if this module is any good, I have not used it, but it does look like it offers just what you may need, http://addons.prestashop.com/en/pricing-promotion-prestashop-modules/13509-multi-accessories-pro-prestamonster.html Link to comment Share on other sites More sharing options...
refloblu Posted December 12, 2015 Author Share Posted December 12, 2015 Hello bill it refers to the product accessories, what i mean is just the "related products" box below my product page ,there is a list of products in the same category Link to comment Share on other sites More sharing options...
Bill Dalton Posted December 12, 2015 Share Posted December 12, 2015 Right That is module productscategory. You will find it here, modules\productscategory\productscategory.php I haven't tried this so make a backup, Change $category_products = $category->getProducts($this->context->language->id, 1, 100); /* 100 products max. */ To $category_products = $category->getProducts($this->context->language->id, 1, 100,'position','DESC'); /* 100 products max. */ Remember to clear all cache after. 1 Link to comment Share on other sites More sharing options...
Bill Dalton Posted December 12, 2015 Share Posted December 12, 2015 You can change DESC to ASC depending on the sort order you want. Link to comment Share on other sites More sharing options...
guillemweb Posted September 2, 2020 Share Posted September 2, 2020 Ohhh fantastic! Thanks for your help! Link to comment Share on other sites More sharing options...
Valentina Calzature Posted November 20, 2020 Share Posted November 20, 2020 On 12/12/2015 at 3:08 PM, Bill Dalton said: Right That is module productscategory. You will find it here, modules\productscategory\productscategory.php I haven't tried this so make a backup, Change $category_products = $category->getProducts($this->context->language->id, 1, 100); /* 100 products max. */ To $category_products = $category->getProducts($this->context->language->id, 1, 100,'position','DESC'); /* 100 products max. */ Remember to clear all cache after. I tried this and it works! It now shows product in descending order by ID product. what if I wanted it to show related products in descendig order by date add/modified? Thank you! Link to comment Share on other sites More sharing options...
Bill Dalton Posted November 20, 2020 Share Posted November 20, 2020 For related products I would suggest looking for a module that allowed you to add related products with options you need. For example I sell clothing, so color match on related items is awesome. Link to comment Share on other sites More sharing options...
Valentina Calzature Posted November 20, 2020 Share Posted November 20, 2020 2 minutes ago, Bill Dalton said: For related products I would suggest looking for a module that allowed you to add related products with options you need. For example I sell clothing, so color match on related items is awesome. thank you for your answer. yes, color match or undercategory match would be also nice (I sell shoes) So, there is no other way than with a module? If I purchased a module for any option I wanted...my Prestashop would crash 🙂 Link to comment Share on other sites More sharing options...
Bill Dalton Posted November 21, 2020 Share Posted November 21, 2020 Yes, I seldom buy a module that works on install. It's one very frustrating thing that I dislike about Prestashop. You will almost always need to contact the module author. It is so stupid. You then need to create a FTP login and give Backoffice access, and wait for this person to make time. And they even want you to give them a good review for what? Fixing something you just paid for? But enough of that rant. Mapping related products will always require humans, but the modules can help with placement and presentation. But to get exactly what you want may also require hiring professional help. It is best to make a list of things that can't be solved any other way and wait until all other things are up and running. Then get quotes for these type of items as one job. It may save money and you should hopefully end up exactly where you want. Keeping in mind, life is a compromise. Link to comment Share on other sites More sharing options...
Valentina Calzature Posted November 22, 2020 Share Posted November 22, 2020 you are right, I have the same problem, especialy when the assistance expires and I have to pay again... Very frustrating. but I think it is the price to pay for a opn source software, in the hads of professionals it allows a freedom that we don't have with other platforms. Anyway after looking here and there I solved the issue, I write it here, in case it is useful for other people. To have related products of the same category but ordered for date added, descent order, I changed $category_products = $category->getProducts($this->context->language->id, 1, 100); /* 100 products max. */ to $category_products = $category->getProducts($this->context->language->id, 1, 100,'date_add','DESC'); /* 100 products max. */ and that works. 1 Link to comment Share on other sites More sharing options...
Bill Dalton Posted November 22, 2020 Share Posted November 22, 2020 Very good of you to share, thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now