randysantino Posted July 5, 2011 Share Posted July 5, 2011 Hi,Can someone help me modify the 'best seller' block?I like to make a sort of Top5 block with best sold products.Since I sell downloads it would be more logical to remove the imagesand make a short description of the title.I would manage to make something like this: ||||||||||| TOP 5 ||||||||||||||| 1) (name-product) - (name-manufacture) (feature description) 2) Billie Jean - Michael Jackson Genre: classics 3) Black Eyed Peas - I gotta feeling Genre: dance 4) etc It shouldn't be hard I think, but I don't have the know-how to do this. Link to comment Share on other sites More sharing options...
MahmutGulerce Posted July 7, 2011 Share Posted July 7, 2011 Hi;Open the /prestashop-root/modules/blockbestsellers/blockbestsellers.tpl file And remove 32th to 35th lines ( ....) > </pre> <ul> getImageLink($best_sellers.0.link_rewrite, $best_sellers.0.id_image, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$best_sellers.0.legend|escape:'htmlall':'UTF-8'}" /> {if $best_sellers|@count > 1}getImageLink($best_sellers.1.link_rewrite, $best_sellers.1.id_image, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$best_sellers.1.legend|escape:'htmlall':'UTF-8'}" />{/if} </ul> Thats all. (ps v1.4.3)Or use an already modified file was attached good luck blockbestsellers.zip Link to comment Share on other sites More sharing options...
randysantino Posted July 8, 2011 Author Share Posted July 8, 2011 @mahmuttaThanks for the reply, but the most important thing for me is that it will show the "productname","manufacturename" and the numbers 1 to 5 where 1 is the best sold product etc....How can I do this? Link to comment Share on other sites More sharing options...
MahmutGulerce Posted July 8, 2011 Share Posted July 8, 2011 HiYou can give numbers by using .... tag in html.Eg: find and change following> </pre> <dl>{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}</dl> to {foreach from=$best_sellers item=product name=myLoop} {$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'} {/foreach} 1 Link to comment Share on other sites More sharing options...
randysantino Posted July 8, 2011 Author Share Posted July 8, 2011 This is what I figured out my self:blocktopseller.php: public function hookRightColumn($params) { if (Configuration::get('PS_CATALOG_MODE')) return ; global $smarty; $currency = new Currency((int)($params['cookie']->id_currency)); $bestsellers = ProductSale::getBestSalesLight((int)($params['cookie']->id_lang), 0, 5); if (!$bestsellers AND !Configuration::get('PS_BLOCK_BESTSELLERS_DISPLAY')) return; $best_sellers = array(); foreach ($bestsellers AS $bestseller) { $bestseller['price'] = Tools::displayPrice(Product::getPriceStatic((int)($bestseller['id_product'])), $currency); $best_sellers[] = $bestseller; } foreach (range(1, 5) AS $number) { $number; } $smarty->assign(array( 'best_sellers' => $best_sellers, 'number' => $number, 'mediumSize' => Image::getSize('medium'))); return $this->display(__FILE__, 'blockbestsellers.tpl'); } And the tpl file: <!-- MODULE Block best sellers --> getPageLink('best-sales.php')}">{l s='Top sellers' mod='blockbestsellers'} {if $best_sellers|@count > 0} {$number} - {$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}{$manufacturer.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'} getPageLink('best-sales.php')}" title="{l s='All best sellers' mod='blockbestsellers'}" class="button_large">{l s='All best sellers' mod='blockbestsellers'} {else} {l s='No best sellers at this time' mod='blockbestsellers'} {/if} <!-- /MODULE Block best sellers --> But all I see is this:5 - (product title)5 - (product title)5 - (product title)5 - (product title)5 - (product title)All the titles have the number 5 before it....But is has to be from 1 to 5 . Link to comment Share on other sites More sharing options...
randysantino Posted July 8, 2011 Author Share Posted July 8, 2011 HiYou can give numbers by using .... tag in html.Eg: find and change following> </pre> <dl>{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}</dl> to {foreach from=$best_sellers item=product name=myLoop} {$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'} {/foreach} Whuahhaa... That's exactly what I mean!I was thinking to hard I guess... LOL Link to comment Share on other sites More sharing options...
MahmutGulerce Posted July 8, 2011 Share Posted July 8, 2011 Hi;Your foreach makes $number integer. So you see "5".You must give a change to smarty. It can do it.You can simple use $smarty.foreach. .index for getting loop ordinate. So Changing {$number} to {$smarty.foreach.myLoop.index} in your TPL file, will fix it.Good luck Link to comment Share on other sites More sharing options...
randysantino Posted July 8, 2011 Author Share Posted July 8, 2011 One more thing (Steve Jobs kinda voice).....How can I echo the manufacturer name? I like to have it BEFORE the product name... Link to comment Share on other sites More sharing options...
MahmutGulerce Posted July 8, 2011 Share Posted July 8, 2011 One more thing (Steve Jobs kinda voice).....How can I echo the manufacturer name? I like to have it BEFORE the product name... Im sorry thats imposible without edit php Block best sellers module, gets only following fieldsArray ( [id_product] => 1 [link_rewrite] => ipod-nano [name] => iPod Nano [description_short] =>asdasdasdlasks as.dç ö.asçdö .aç [id_image] => 1-37 [legend] => iPod Nano [sales] => 14 [ean13] => 0 [upc] => [category] => music-ipods [link] => http://......ct=1 ) You may query Product by id_product than get Manufacturer by product->id_manufacturer .... Link to comment Share on other sites More sharing options...
randysantino Posted July 8, 2011 Author Share Posted July 8, 2011 You may query Product by id_product than get Manufacturer by product->id_manufacturer .... Thank you Mahmutta.Can you help me with the code?? Link to comment Share on other sites More sharing options...
MahmutGulerce Posted July 8, 2011 Share Posted July 8, 2011 You may query Product by id_product than get Manufacturer by product->id_manufacturer .... Thank you Mahmutta.Can you help me with the code?? Find following lines 100-101 in blockbestseller.phpforeach ($bestsellers AS $bestseller) { Add this lines after it $pro = new Product ($bestseller['id_product'], (int)($params['cookie']->id_lang)); $man = new Manufacturer($pro->id_manufacturer); $bestseller['manufacturer'] = $man->name; Replace line 34th in blockbestseller.tpl to following {$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'} {$product.manufacturer} thats allModified files attached bestsellers.zip Link to comment Share on other sites More sharing options...
randysantino Posted July 8, 2011 Author Share Posted July 8, 2011 mahmutta: You're my man!Thank you so much!!Good to learn from you. Link to comment Share on other sites More sharing options...
MahmutGulerce Posted July 8, 2011 Share Posted July 8, 2011 mahmutta: You're my man!Thank you so much!!Good to learn from you. ;)I am glad it worked and get a new friend. Good luck Link to comment Share on other sites More sharing options...
randysantino Posted July 8, 2011 Author Share Posted July 8, 2011 Sorry to border you one more time my friend ;-)Now I want to show one value of the features. This is what I tried so far:Php file after foreach ($bestsellers AS $bestseller) { $pro = new Product ($bestseller['id_product'], (int)($params['cookie']->id_lang)); $man = new Manufacturer($pro->id_manufacturer); $bestseller['manufacturer'] = $man->name; I put this $feat = new Feature ($bestseller['id_feature'], (int)($params['cookie']->id_lang)); $featval = new FeatureValue($feat->id_feature_value); $bestseller['feature'] = $featval->value; And in tpl file (got it from my 1.3.7 template): {foreach from=$product.features item=feature} {if $feature.name eq "Genre: "}{$feature.value}{/if} {/foreach} Must be doing stupid here... :-sCan you help me one more time please? Link to comment Share on other sites More sharing options...
MahmutGulerce Posted July 8, 2011 Share Posted July 8, 2011 Dear randysantinIts possible too to show features but will use more and more resource. So it makes your store slower. Link to comment Share on other sites More sharing options...
randysantino Posted July 8, 2011 Author Share Posted July 8, 2011 Never thought about that.... in that case you're right.I must keep it simple!Thanks again for your help! Link to comment Share on other sites More sharing options...
gypsy Posted November 17, 2012 Share Posted November 17, 2012 hey can you please give me a link to this module I stupidly deleted by mistake when trying to add one of the zips you posted 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