Jump to content

Need a modules for auto (car) parts


Recommended Posts

Hello Everyone,

 

I'm working on a Presashop store for my online auto parts business. My eBay store is located at:

 

I want a module (free or paid) to simulate that 'compatibility' part of the mentioned website. Any inights are appreciated.

 

 

PS: I tried using tags for the thing, but it seems that they are not searchable / configurable. I want something like make/model/year.

 

Thanks!

Link to comment
Share on other sites

  • 2 months later...

i'd love to hear how you implemented the "by brand / model / year" filtering.

Layered navigation does not display categories so building a Audi -> A3 -> 2006 heierarchy of categories for example does not help (since it won't be displayed as a layered navigation option.

Link to comment
Share on other sites

  • 2 months later...

I'm also very interested in what you have accomplished Anoush Ravan. I'm not good in programming. Do you mind sharing your knowledge? Thank you in advance.

 

Yes. Basically, I added a file to handle AJAX requests in blocklayered module:

 

<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
// What mode are we running
$myMode = (int)Tools::getValue('mode');
// params
$myMake = (int)Tools::getValue('make');
$myModel = (int)Tools::getValue('model');
if ($myMode){
switch ($myMode){
 case 4:
  echo json_encode(getMakes());
 break;
 // Models
 case 5:
  echo json_encode(getModels($myMake));
 break;
 // Years:
 case 6:
  echo json_encode(getYears($myMake, $myModel));
 break;
}
}
return true;
/* functions */
// Get all makes by cross joining products table
function getMakes(){
 $makes = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
 SELECT al.id_attribute, al.name FROM ps_attribute_group ag
 JOIN ps_attribute a ON (a.id_attribute_group = ag.id_attribute_group)
 JOIN ps_attribute_lang al ON (al.id_attribute = a.id_attribute) WHERE
 ag.id_attribute_group = 4 AND id_lang = 1 ORDER BY al.name DESC  ');
 // No makes is an error
 if (!$makes)
  return NULL;

 return $makes;
}
//  Grab all models based on this make, from products.
function getModels($myMake){
if(!is_int($myMake))
 return NULL;

$models = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT DISTINCT(al.name), al.id_attribute FROM ps_layered_product_attribute lpa1
JOIN ps_layered_product_attribute lpa2 ON (lpa1.id_product = lpa2.id_product)
JOIN ps_attribute_lang al ON (lpa2.id_attribute = al.id_attribute )
WHERE lpa1.id_attribute = '.$myMake.' AND lpa2.id_attribute_group = 5 ORDER BY al.name DESC  ');
// empty
if (!$models)
 return NULL;

return $models; 
}
// Grab all the years from this make + model selection
function getYears($myMake, $myModel){
if(!is_int($myMake) OR ! is_int($myModel))
 return NULL;

$years = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('SELECT
   DISTINCT(al.name), al.id_attribute  FROM ps_layered_product_attribute lpa1
   JOIN ps_layered_product_attribute lpa2 ON (lpa1.id_product = lpa2.id_product)
   JOIN ps_layered_product_attribute lpa3 ON (lpa2.id_product = lpa3.id_product)
   JOIN ps_attribute_lang al ON (lpa3.id_attribute = al.id_attribute )
   WHERE lpa1.id_attribute = '.$myMake. ' AND lpa1.id_attribute_group =4
   AND lpa2.id_attribute =   '.$myModel.' AND lpa2.id_attribute_group = 5
   AND lpa3.id_attribute_group = 6 ORDER BY al.name DESC ');
if(!$years)
 return NULL;

return $years; 
}






Link to comment
Share on other sites

And this to GENERATE those requests. i modified my blockcategories from my theme, but should be applicable to default module as well:

{$showMMY = !($page_name == 'category' || $page_name == 'product')}
<!-- straight up JS to make MMY working. -->
{if $showMMY }
{literal}
<script type='text/javascript'>
$(document).ready(function() {
// make sure we are on the same page
if ( $('ul.mmy-selector').length > 0 ){
 // Change page's name
 $('#top-categ').find('span').text('Make, Model, Year Search');
 // load the makes initially.
 $.ajax({
   url: '/modules/blocklayered/blocklayered-ajax-r.php',
   data: {mode: 4},
   type: "POST",
  dataType: "JSON",
   success: function (makes){$.each (makes, function (){
  // Append the option bar
  $('#make-selector')
  .append($("<option></option>")
  .attr("value",this.id_attribute)
  .text(this.name));
  });
  $('#make-selector').parent().find('.mmy-loader').hide();
   },
 });
 // Bind event to this one's change attr and fill up the models
 $(document).on('change', '#make-selector', function(){
   $('#model-selector').parent().find('.mmy-loader').show();
   // Send another AJAX request with mode 5 (model) and key 4 (make)
   $.ajax({
   url: '/modules/blocklayered/blocklayered-ajax-r.php',
   data: {mode: 5, make: $('#make-selector').val()},
   type: "POST",
	 dataType: "JSON",
   success: function (models){
    // remove previous options rather than nullifier
    $('#model-selector')
	  .find('option')
	  .remove()
	  .end()
	  .append('<option disabled="disabled" selected="selected">Select...</option>');

   $.each (models, function (){
	 // Append the option bar
	 $('#model-selector')
	 .append($("<option></option>")
	 .attr("value",this.id_attribute)
	 .text(this.name));
   });
  $('#model-selector').parent().find('.mmy-loader').hide();
   },
   });
 });
 // Bind event to model change. pick up years and we're ready to go
 $(document).on('change', '#model-selector', function(){
   $('#year-selector').parent().find('.mmy-loader').show();
   // Send another AJAX request with mode 5 (model) and key 4 (make)
   $.ajax({
   url: '/modules/blocklayered/blocklayered-ajax-r.php',
   data: {mode: 6, make: $('#make-selector').val(), model: $('#model-selector').val()},
   type: "POST",
	 dataType: "JSON",
   success: function (years){
    // remove previous options rather than nullifier
    $('#year-selector')
	  .find('option')
	  .remove()
	  .end()
	  .append('<option disabled="disabled" selected="selected">Select...</option>');

   $.each (years, function (){
	 // Append the option bar
	 $('#year-selector')
	 .append($("<option></option>")
	 .attr("value",this.id_attribute)
	 .text(this.name));
   });
   $('#year-selector').parent().find('.mmy-loader').hide();
   },
   });
 });
 // Bind event to the button
 $(document).on('click', '#mmy-go', function(){
  if ($("#make-selector ")[0].selectedIndex <= 0) {
		    $("#make-selector").prev().css({color:'red'});
		    return false;
	    }
  if ($("#model-selector ")[0].selectedIndex <= 0) {
		    $("#model-selector").prev().css({color:'red'});
		    return false;
	    }
  if ($("#year-selector ")[0].selectedIndex <= 0) {
		    $("#year-selector").prev().css({color:'red'});
		    return false;
	    }
	    // Down here everything is fine, we can simply go
	    var searchString = $('#make-selector option:selected').text() + ' ' +  $('#model-selector option:selected').text() + ' ' + $('#year-selector option:selected').text() ;

	    // paste it into the search box
	    $('#search_query_top').val(searchString);
	    // hit submit
	    $('#search_query_top').next().click();
 });
// End ready and if
}
}); 
</script>
{/literal}
{/if}
<!-- Block categories module -->
<div id="categories_block_left" class="demo-container block">
<div class="tptn-vertical-mega-menu">
{if $showMMY }
<!-- Do the triple level select boxes and a submit button for MMY search -->
<ul id="mega-1" class="menu right mmy-selector">
 <li>
  <a href="#">
  <label for="make-selector">Make: </label>
  <select name="make-selector" id="make-selector">
   <option disabled="disabled">Select...</option>
  </select>
  <img src="{$img_ps_dir}mmy-loader.gif" class="middle mmy-loader" alt="" id="stores_loader" />   </a>
 </li>
 <li>
  <a href="#">
  <label for="model-selector">Model: </label>
  <select name="model-selector" id="model-selector">
   <option disabled="disabled">Select Make.</option>
  </select>
  <img src="{$img_ps_dir}mmy-loader.gif" class="middle mmy-loader" alt="" id="stores_loader" style="display: none; !important;" />   </a>
  </a>
 </li>
 <li>
  <a href="#">
  <label for="year-selector">Year: </label>
  <select name="year-selector" id="year-selector">
   <option disabled="disabled">Select Make.</option>
  </select>
  <img src="{$img_ps_dir}mmy-loader.gif" class="middle mmy-loader" alt="" id="stores_loader" style="display: none; !important;" />   </a>
  </a>
 </li>
 <li>
  <a href="#">
  <button id="mmy-go"> Find my Part</button>
  </a>
 </li> 
</ul>

{else}
 <ul id="mega-1" class="menu right">
 {foreach from=$blockCategTree.children item=child name=blockCategTree}
  {if $smarty.foreach.blockCategTree.last}
   {include file="$branche_tpl_path" node=$child last='true'}
  {else}
   {include file="$branche_tpl_path" node=$child}
  {/if}
 {/foreach}
 </ul>
{/if}
</div>
</div>
<!-- /Block categories module -->
 
Edited by Sean Raviolli (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 1 year later...
  • 2 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...