jerrrrrrrry Posted September 23, 2011 Share Posted September 23, 2011 i'm new in prestashop, what i have interstood is that in ordor to display the manufacturer name of the product in the new product block, i have i have to override BestSalesControllerCore and maybe function getBestSales(), am i right? how can i do that? class BestSalesControllerCore extends FrontController { public $php_self = 'best-sales.php'; public function process() { $this->productSort(); $nbProducts = (int)(ProductSale::getNbSales()); $this->pagination($nbProducts); self::$smarty->assign(array( 'products' => ProductSale::getBestSales((int)(self::$cookie->id_lang), (int)($this->p) - 1, (int)($this->n), $this->orderBy, $this->orderWay), 'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'), 'nbProducts' => $nbProducts, 'homeSize' => Image::getSize('home') )); } here is public static function getBestSales($id_lang, $pageNumber = 0, $nbProducts = 10, $orderBy=NULL, $orderWay=NULL) { if ($pageNumber < 0) $pageNumber = 0; if ($nbProducts < 1) $nbProducts = 10; if (empty($orderBy) || $orderBy == 'position') $orderBy = 'sales'; if (empty($orderWay)) $orderWay = 'DESC'; $groups = FrontController::getCurrentCustomerGroups(); $sqlGroups = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1'); $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS(' SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, m.`name` AS manufacturer_name, p.`id_manufacturer` as id_manufacturer, i.`id_image`, il.`legend`, ps.`quantity` AS sales, t.`rate`, pl.`meta_keywords`, pl.`meta_title`, pl.`meta_description`, DATEDIFF(p.`date_add`, DATE_SUB(NOW(), INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new FROM `'._DB_PREFIX_.'product_sale` ps LEFT JOIN `'._DB_PREFIX_.'product` p ON ps.`id_product` = p.`id_product` LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1) LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($id_lang).') LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`) LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group` AND tr.`id_country` = '.(int)Country::getDefaultCountryId().' AND tr.`id_state` = 0) LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`) WHERE p.`active` = 1 AND p.`id_product` IN ( SELECT cp.`id_product` FROM `'._DB_PREFIX_.'category_group` cg LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`) WHERE cg.`id_group` '.$sqlGroups.' ) ORDER BY '.(isset($orderByPrefix) ? $orderByPrefix.'.' : '').'`'.pSQL($orderBy).'` '.pSQL($orderWay).' LIMIT '.(int)($pageNumber * $nbProducts).', '.(int)($nbProducts)); if ($orderBy == 'price') Tools::orderbyPrice($result,$orderWay); if (!$result) return false; return Product::getProductsProperties($id_lang, $result); } here is tpl {if $new_products !== false} <ul class="product_images clearfix"> {foreach from=$new_products item='product' name='newProducts'} {if $smarty.foreach.newProducts.index < 2} <li{if $smarty.foreach.newProducts.first} class="first"{/if}>{$product.name|escape:html:'UTF-8'}{$product.id_manufacturer}{$product.manufacturer}<a href="{$product.link}" title="{$product.legend|escape:html:'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$product.legend|escape:html:'UTF-8'}" /></a></li> {/if} {/foreach} </ul> <dl class="products"> {foreach from=$new_products item=newproduct name=myLoop} <dt class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link}" title="{$newproduct.name|escape:html:'UTF-8'}">{$newproduct.name|strip_tags|escape:html:'UTF-8'}</a></dt> {if $newproduct.description_short}<dd class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$newproduct.link}">{$newproduct.description_short|strip_tags:'UTF-8'|truncate:50:'...'}</a> <a href="{$newproduct.link}"><img src="{$img_dir}bullet.gif" alt=">>" width="10" height="7" /></a></dd>{/if} {/foreach} </dl> <p><a href="{$link->getPageLink('new-products.php')}" title="{l s='All new products' mod='blocknewproducts'}" class="button_large">{l s='All new products' mod='blocknewproducts'}</a></p> {else} <p>{l s='No new products at this time' mod='blocknewproducts'}</p> {/if} any help would be great Link to comment Share on other sites More sharing options...
rocky Posted September 25, 2011 Share Posted September 25, 2011 I don't understand why you need to change any queries. It appears the manufacturer name is already in the query (m.`name` AS manufacturer_name). Just use {$product.manufacturer_name} in the TPL file where you want to display the manufacturer name. 1 Link to comment Share on other sites More sharing options...
jerrrrrrrry Posted September 30, 2011 Author Share Posted September 30, 2011 thanks you , its works Link to comment Share on other sites More sharing options...
JackTheRipper Posted December 29, 2011 Share Posted December 29, 2011 I don't understand why you need to change any queries. It appears the manufacturer name is already in the query (m.`name` AS manufacturer_name). Just use {$product.manufacturer_name} in the TPL file where you want to display the manufacturer name. rocky if i want to display manufacturer logo what line i have to use? (sorry for my poor english) Link to comment Share on other sites More sharing options...
bellini13 Posted December 29, 2011 Share Posted December 29, 2011 the database does not store the image information, you just need to check if the image exists in the right directory. manufacturer images are stored in the /img/m directory. the name of the image would contain the id of the manufacturer. the manufacturer controller does the following... foreach ($manufacturers AS &$row) $row['image'] = (!file_exists(_PS_MANU_IMG_DIR_.'/'.$row['id_manufacturer'].'-medium.jpg')) ? Language::getIsoById((int)self::$cookie->id_lang).'-default' : $row['id_manufacturer']; 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