Jump to content

filter products by features


Recommended Posts

Hi , i would like to develop a module that would help the user filter the products by the available features 

 

So , for example , if i have a product " Hard disk Samsung " , with the features 7200RPM , Samsung , 500GB and 8 MB Cache , i would like these features to appear on the left side. This would apply for all the available products in the database , so if i would click the feature " samsung " it would retrieve all the available Samsung products.

 

Could someone give me a little guidance to how i could achieve this ? Any help would be greatly appreciated. I'm pretty sure there are already modules availble to achieve this , but i would like to develop my own module if possible. I'm sorry if i posted in the wrong section.

Link to comment
Share on other sites

  • 2 weeks later...

Hello again , i'm trying to display the result of a sql querry in a tpl file , but i get the error Parse error: syntax error, unexpected ''results'' (T_CONSTANT_ENCAPSED_STRING), expecting ')' in D:\XAMPP\htdocs\prestashop\modules\mymodule\mymodule.php on line 72

 

i followed the tutorial from here http://doc.prestashop.com/display/PS16/Creating+a+PrestaShop+Module

 

mymodule.php

 public function hookDisplayLeftColumn($params)
{ 
  $result = Db::getInstance()->executeS('SELECT * FROM ps_category where id_category = 1 ');
  if(!$result)
  return "error";
  
  $results = array();
  foreach ($result as $results){
     array_push($results, array(
                'id_category' => $results['id_category']
                
            ));
  
  }
  
  $this->context->smarty->assign(
      array(
          'my_module_name' => Configuration::get('MYMODULE_NAME'),
          'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display')
          'results' => $results
	  )
  );
  return $this->display(__FILE__, 'mymodule.tpl');
}
   
public function hookDisplayRightColumn($params)
{
  return $this->hookDisplayLeftColumn($params);
}
   
public function hookDisplayHeader()
{
  $this->context->controller->addCSS($this->_path.'css/mymodule.css', 'all');
}  

mymodule.tpl

<!-- Block mymodule -->
<div id="mymodule_block_home" class="block">
  <h4>Configurator</h4>
  <div class="block_content">
    <p>Hello,
       {if isset($my_module_name) && $my_module_name}
           {$my_module_name}
       {else}
           World
       {/if}
       !       
    </p>   
    <ul>
      <li><a href="{$my_module_link}" title="">Click Me!</a></li>
    </ul>
  </div>
</div>
<!-- /Block mymodule -->

display.php

<?php
class mymoduledisplayModuleFrontController extends ModuleFrontController
{
  public function initContent()
  {
    parent::initContent();
    $this->setTemplate('display.tpl');
  }
}

display.tpl

asdf

what i am trying to do is print the results of $results variable (which should contain the querry result) into display.tpl using Smarty

 

display.tpl

{results}

but i get the error message that i posted above. Any help would be greatly appreciated

 

I didn't create a new topic , i hope this is good practice on the forum 

 

Link to comment
Share on other sites

Missing comma here, after the second element

 

 

  1. $this->context->smarty->assign(
  2. array(
  3. 'my_module_name' => Configuration::get('MYMODULE_NAME'),
  4. 'my_module_link' => $this->context->link->getModuleLink('mymodule', 'display')
  5. 'results' => $results
  6. )
  7. );
Link to comment
Share on other sites

×
×
  • Create New...