Jump to content

[Job offer]


MotoCCnl

Recommended Posts

Im currently converting my shop from zen cart to prestashop and now im looking for somebody who can build an module for me.

 

This module has an database with 6tables:

id | id_product | make | model | bof_year | eof_year

1 | 999 | Honda | CBR900RR | 2000 | 2005

 

The module consist of 2 parts,

PART1 is 3 dropdown boxes as seen on picture 1

The first box shows all available brands, once a brand is selected the second box shows all available types of that brand you selected, the same happens with the third box, witch shows all available years.

 

This is all done by an javascript (from witch i have the code)

 

Once selected all products for that selection is shown, and the selection (make/model/year) is stored in a cookie for later use.

 

PART2 is an tab in the products page witch shows all the make/model/bof_year - eof_year this product is mentioned in in the database (picture 2)

 

I have this working on my zen cart site, but i need it for prestashop. I can provide you with all the codes that are used for this module within zen cart so that you have something to start with.

 

Picture 1:

1.png

Picture 2:2.png

Link to comment
Share on other sites

This module has an database with 6tables:

id | id_product | make | model | bof_year | eof_year

1 | 999 | Honda | CBR900RR | 2000 | 2005

You mean a table with 6 field - yes?

 

PART1 is 3 dropdown boxes as seen on picture 1

This is all done by an javascript (from witch i have the code)

You mean it is attached to a side or the header or the footer of your pages right? Or is a BO module?

 

Once selected all products for that selection is shown, and the selection (make/model/year) is stored in a cookie for later use.

Does the cookie content need to be accessible by non in Prestashop scripts?

 

 

Best,

(d)oekia

Link to comment
Share on other sites

You mean a table with 6 field - yes?

 

Yes, i meant 6 fields yes.

 

You mean it is attached to a side or the header or the footer of your pages right? Or is a BO module?

 

Its currently an in-line javascript, so i can place the module everywhere i want (in the shop itself). It's fine by me if its placed in the side.

 

Does the cookie content need to be accessible by non in Prestashop scripts?

 

No, its just that if the customer comes back after a few days, its still remembers his choose

Link to comment
Share on other sites

Fine.

I guess you almost have every thing

Creating a front-office module is quite easy (need some programing skills but not too much)

Once you have done that just make an ajax call for the onchange events that will push the values directly inside the Prestashop cookie - do the first, I'll help you if you have trouble doing such.

 

We may do that in such a way as a tutorial for every one

They will follow your progress and I will guide you along the path

 

How do you feel about that?

Link to comment
Share on other sites

Well to be real honest, for me its just trial and error with copy/paste and modify.

It's not that really know and can explain what i'm doing, it just that i keep trying till it works.

 

But if you can help me i'm willing to make it a free module available for everybody

Link to comment
Share on other sites

Well maybe you can help me with the following:

 

I took the code witch i use in zen cart and put it in a module. I made a hook for the left sidebar and i got the inline javascript file working (it gives the same output as it does on my old shop)

 

it's just the last bit of code i can't get to work:

 

   if (isset($Make_selected_var) && isset($M_a[$Make_selected_var])){
  foreach ($M_a[$Make_selected_var] as $k => $v)
 $Model_array[] = array('id' => $k, 'text' => $k);}
if (isset($Make_selected_var) && isset($Model_selected_var) && isset($M_a[$Make_selected_var][$Model_selected_var]))
  foreach ($M_a[$Make_selected_var][$Model_selected_var] as $k => $v)
 $Year_array[] = array('id' => $k, 'text' => $k);

  $script = basename('index');
  $script2 = basename('index.php');
  $action = $script2;
   $html .= $javascript;
  $html .= zen_draw_form('make_model_year', $action, 'get');
  $html .= zen_draw_pull_down_menu('Make', $Make_array, (isset($Make_selected_var) ? $Make_selected_var : ''), 'onChange="pop_model();"  style="width: 100%"') .'<br><br>';
 $html .= '<span id="model_select">'.zen_draw_pull_down_menu('Model', $Model_array, (isset($Model_selected_var) ? $Model_selected_var : ''), 'onChange="pop_year();" style="width: 100%"') .'</span><br><br>';
 $html .= '<span id="year_select">'.zen_draw_pull_down_menu('Year', $Year_array, (isset($Year_selected_var) ? $Year_selected_var : ''), 'onChange="document.make_model_year.submit();" style="width: 100%"') .'</span><br><br>';
 $html .= '<input type="submit" value="Go">   <a href="'.zen_href_link($script).'">Wis selectie</a>';

 

If i understand it correctly the first part makes an array, and the second part makes the dropdowns with that array.

But whatever i try, i get empty dropdows or no dropdowns at all.

 

The idea i had is to put everything in the variable $html and make a "return $html;"

Link to comment
Share on other sites

Ok for the clarity if the topic, do you mind posting your files as attachment (and remove those huge code snippets).

Without the entire context we will do trail & fail for support and fix and this makes the topic more difficult to read.

I'll do the same unless it is no more than 2 lines of codes.

 

The function zen_xxx are zencart specific function we don't have that here and we don't need

Once you have all your var set, you pass them to smarty, and you build anything you want thru a template.

 

A template is basically a portion of HTML in which you display your vars thru a set of {$myvar}

Hint, view the page source of your apps in the zencart, cut and paste the portion into a file called mymodule.tpl

when you want to display the content you do return return $this->display(__FILE__, 'mymodule.tpl');

Link to comment
Share on other sites

so similar to the your function hookProductTab has the following line code

 

return $this->display(__FILE__, 'partsfiltertab.tpl');

 

you need to add something similar to the hookLeftColumn function. the difference is you need to place your "content", which is $content, inside the smarty engine, so that it can be used by a template to display the information on the browser

 

$smarty->assign('content', $content);
return $this->display(__FILE__, 'content.tpl');

 

then you need to create a file called content.tpl that would display the "content"

{$content}

Link to comment
Share on other sites

thanks, but i cant get it to work, i changed the code like you suggested but nothing shows up.

Everything works fine right till this code:

{foreach $ymm as $k => $r}

If i put something above that line it shows up, but if i put something underneath it, nothing shows up

Any ideas?

Link to comment
Share on other sites

Ok, this is what i get: (i removed some info i dont want te get public :P)

 

<-- MySQL Object ( [_server:protected] => localhost [_user:protected] => root [_password:protected] => REMOVED [_type:protected] => MySQL [_database:protected] => REMOVED [_link:protected] => Resource id #8 [_result:protected] => Resource id #264 [_lastQuery:protected] => SELECT `id_customer` FROM `customer` WHERE `id_customer` = 2 AND `passwd` = 'REMOVED' LIMIT 1 [_lastCached:protected] => ) -->

Link to comment
Share on other sites

Well i can't get the php working for the dropdown, maybe u can have a look at it?

 

I started with changing the mysql query to to work with "Db::getInstance()->ExecuteS"

But then there is this code on line 76:

if ($number_of_rows = mysql_num_rows($Make_Model_Year_query)) {

and this code on line 91:

while ($Makes = mysql_fetch_array($Make_Model_Year_query)) {

i cant find an equivalent for it to work in prestashop

 

my idea is to do all the php in the partsfilter.php file, and then show the output in an ,tpl file, this saves me a lot of coding

I've attached the module so far so u can have a look.

partsfilter.zip

Link to comment
Share on other sites

In fact the ExecuteS does the fetching for you. At the end you get an array of array of field values.

So if you do a count($result) you know how many rows and by indexing directly your array you immediately get access to the data.

 

I take a look of you file in the late evening doo

Link to comment
Share on other sites

Ok, so if i understand correctly the first needs to be:

if ($number_of_rows = count($Make_Model_Year_query)) {

(wow i tried almost everything and then is something so easy)

 

But you say the data is already fetched, so then the second line should be:

while ($Makes = $Make_Model_Year_query) {

Only this gives me a white screen

Link to comment
Share on other sites

hahah no it is'nt a model of simplicy no, but it did the trick (it was originaly for oscommerce and i ported it to zen cart)

 

but in yours comment you mention that the javascript has to be rewritten, and to be honest, i have no idea how.

For the php i look at existing codes and try to make some sens of it, but i cant make any sens at all of the javascript.

 

And i really have no idea how to go on now, i hoped i could stay as close to the original code as possible, because im not a php coder, i just alter the codes to get i working like i want to.

 

if you want to see the script working on my (zen cart) webshop you should go to http://www.motocc.nl/motorfilter this is basicly what i want.

Link to comment
Share on other sites

well actually at that point i had the javascript working and giving the same output as my shop.

So basicly i know for sure that i got everything working right up till line 175 in the partsfilter.php file

 

I was now trying to figure out a way to get the output of that javascript to show up in 3 dropdowns in a .tpl file

partsfilter.php

Link to comment
Share on other sites

There is a question however.

 

Is this only to display a list of product based on a serie of characteristics?

Have you try implementing that using faceted navigation?

You create feature that you attach to your product and the user just select and the list of matching products appear

Link to comment
Share on other sites

What i want to create are 3 dorpdowns in witch the customer can select his motorcycle and then show the product that are availible for his motorcyle (or cars for other shops).

 

I've looked at the feature option of prestashop, but there are 2 major problems for me.

1) a product can be available for more then 1 motorcycle, and i haven't found a way to do that easy and quick in prestashop

2) the existing database for the filter contains over 9000 rows, it would take me weeks to redo all that.

Link to comment
Share on other sites

haha yeah i understand i was just a question, i ment no harm with my answer, its just that i dont really know how to explain why the feature function doesnt work for me.

 

Like you see in the second picture of the first post of this topic, one product can be for multiple brands, multiple models, and multiple years, and to make it even wors, it doesnt nessesarily overlap, for example

 

product 1 can be used on: Honda CBR900RR build between 2000 and 2009 and

product 2 can also be used on the Honda CBR900RR but then only for the ones build between 2005 and 2010 (for example)

Link to comment
Share on other sites

In fact I think I understand

And if we set a feature on the product 1 to CBR900RR + 2000 + 2009

And on product2 CBR900RR + 2005 + 2010

 

I think they'll be able to find the products

Reason I ask is because after that because it is a feature it indexed by Prestashop

So if rather that the guy enter CBR in the search box product appears and on the product page they realise yes it is for CBR900RR not CBR666Z3 (I am a total illiterate regarding motorcycle)

Link to comment
Share on other sites

Yes if been thinking of that search function to, but i hoped it would be able to add the parts database (products_ymm) to the searchfields (maybe something for a later moment)

 

The problem is the following, if i would put the feature like you suggest, it would show in the faceted navigation: CBR900RR in model, and the years 2000,2005,2009 and 2010 as years. But what if i got a 2008 year? then both product 1 and 2 are availble, but sinds it doesn't show up in the faceted navigation customers won't find it

Link to comment
Share on other sites

Btw, not only that, the way the module now works it also shows other products.

 

For example, i select:

Make: Honda

Model: CBR900RR

Year: 2008

 

But there is a product that is availible for all models from honda's, instead of putting all combinations in the database, i only put in the productnr and make Honda and leave everything else blank. The is still shows up for every selection with the make Honda

Link to comment
Share on other sites

Pretty easily:

jQuery.ajax({
   type: 'POST',
   url: baseDir + 'modules/partsfilter/partsfilter-ajax.php',
   async: false,
   cache: false,
   type : "POST",
   dataType : "json",
   data: { make: 1, model: 2 // lWHATEVER },
   success: function(jsonData)
   {
 //Proces the result
  return;
   }

 

Have a look to blocklayered-ajax.php to build your ajax dispatcher (basically it pout back to a function you have to create in your module.

Link to comment
Share on other sites

Hahaha you mean pretty easy for you? :P This will be the first time i will work with ajax myself.

 

And i think i understand what the blocklayered-ajax.php does, it creates a new function, an function that is declared in blocklayered.php, and thats where i get stuck, i can't get much sens out of that.

 

And that jQuery.ajax() do i have to call to that onchange? so like:

var o ="<select name=\"Year\" style=\"width: 100%\" onChange=\"jQuery.ajax();\"><option value=\"0\">Jaar</option>";

Link to comment
Share on other sites

Yes sort of

In the function your -ajax.php is calling, you fetch the arguments, you identify the product, then you return the product page content ... the snippet i sended you use json but if you change the method to html all you have to do after that is finding the center column element and insert the html in $('#center_column').innerHtml($result);

Link to comment
Share on other sites

well i tried a lot of thinks but i cant seem to figure out how it works with ajax

 

The original script reloaded the page with this in the url:

?Make=Honda&Model=CBR+900+RR&Year=2000

 

and then used an $_GET['Make'], $_GET['Model'] and $_GET['Year'] to set a cookie and to set an database query

 

I think if i made a hook foor the top of each page i could manager to get i working that way... but thats no ajax unfortantly

Link to comment
Share on other sites

If you accept a reload, all we need to do is passing the product page directly

 

I need to change the code we build yesterday because I did not provide the JS with the relation selection/product_id

My "smart" loop kills it all

 

 

In fact the query we did yesterday should fetch the product id from your table... and keep the assoc... I'm just concerned by to performances at the end ... BAD SOLUTION

 

Performance should be addressed as follow:

Keep yesterday code as is

On option change kick off a json ajax request

The ajax function fetch the params and do a database request to return the product id (and product link)

On ajax success we redirect the user to the product page

 

GOOD SOLUTION

Link to comment
Share on other sites

Well it would be nice if it could be done with ajax and to have no reload. But sinds i cant get it to work i have no choise.

 

About the code from yesterday, i think you mean the code from post #23? I took that out of the code to stay as close as possible to the original code

 

About the performance, i know it wont be great, because everytime you load the 3 dropdowns and everytime you do a search it will search the intire products_ymm table (in my case over 9000 lines) That why i eventually want to make a seperate page for the module (instead of in the sidebar) that way it won't be reloaded everytime you visit a page

 

Like i told you, im not a php programmer, i know its not the best way, but its the only way i know because i only have to alter existing codes.

 

I just don't know how to rewrite the code to work with ajax, so unless you volunteer to rewrite :P i have to stick to the original code

Link to comment
Share on other sites

Yes post #23.

 

Let's starts with the ajax. We need an entry point

<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
include(_PS_ROOT_DIR_.'/init.php');
$module = basename(dirname(__FILE__));
require_once(_PS_MODULE_DIR_.$module.'/'.$module.'.php');
$instance = new ${$module}();
echo $instance->ajaxCall();

This goes to a file called /modules/partsfilter/partsfilter-ajax.php

 

Create a public function in the module file called ajaxCall

 

For the time been, point your browser to http://<shop>/modules/partsfilter/partsfilter.php?make=1&model=2&bof=1998&eof=2010

and manage to fetch the database for the record matching this selection - create a product object new Product($id_product) and return the json_encode of the product.

 

Once this been done we will glue all the things together.

 

PS: You are not a PHP programmer but you have some skill. And at the end the understanding an fame of this been your stuff.

Edited by doekia (see edit history)
Link to comment
Share on other sites

well my skill is that i try to understand the logic of the code, so i understand what the codes you give me do (well most of them). But when i need to write my own code (like creating a product object) i don't know how to do that.

 

and i guess the code is based on the code from post #23? problem is that that code doesn't show 3 dropdowns and all the pages are shown blank

 

Btw, &bof=1998&eof=2010 needs to be &year=2000 the customer needs to select the year his bike is from, an then the script needs to figure out witch product are availible for that

Link to comment
Share on other sites

bof and eof are just parameters you name then the way you like it is not for display it is a variable

 

Yes on the code from post#16, add the ajaxCall function

fetch your params: $make = Tools::getValue('make');

do a db query using the params 'select * from MC... where 1' if ($make) ' and make="'.pSQL($make).'"'

if ($result), if count($result) == 1

$product = new Product($result[0]['id_product']);

return json_encode($product);

else

Please refine your search

else else Sorry nothing match your search

 

this is not real code !!

Link to comment
Share on other sites

ok, im gonna be real cocky here (im very sorry)

 

I really really appreciate your help, but instead of rewriting the code so it works with ajax, im first gonna try to make entire the module work like it does now in zen cart, so with the page reload and the url and everything.

 

Reason for this is that i really need to get the new site up and running sinds the current site has a lot of issues (witch really cost me in sales) before i can get the new site running i need to transfer 6000 products, and have a working filter.

 

Once the new site is up and running (in about a week) i have enough time to make the script perfect, and to experiment with the ajax. So again, I really really appreciate your help, and i really want to continue with this, its just that i need the module to work before i can put any time in learning ajax, and making the module better.

Link to comment
Share on other sites

Here is the PHP side of the ajax connector.

 

For you TODO, generate a SQL query taking account of bof and eof

 

To see it running point your browser to the -ajax.php then add parameters such a make model and the like in the arguments

see how it behave.

 

BTW typo in the -ajax should be: $instance = new $module();

partsfilter.php

Edited by doekia (see edit history)
Link to comment
Share on other sites

hmmm, i didn't door de sql for the years yet, but when i visit this link:

http://localhost/motocc/modules/partsfilter/partsfilter-ajax.php?Make=Honda&Model=CBR+900+RR (so i want to show the product voor the honda cbr 900 rr it shows:

 

{"message":"More than one product match. Add more criteria","count":5,"rows":[{"name":{"1":"Aprilia Atlantic 500","2":"Aprilia Atlantic 500","3":"Aprilia Atlantic 500","4":"Aprilia Atlantic 500","5":"Aprilia Atlantic 500","6":"Aprilia Atlantic 500"[spam-filter],{"name":{"1":"Aprilia ETV1000 (2000 t\/m 2003)","2":"Aprilia ETV1000 (2000 t\/m 2003)","3":"Aprilia ETV1000 (2000 t\/m 2003)","4":"Aprilia ETV1000 (2000 t\/m 2003)","5":"Aprilia ETV1000 (2000 t\/m 2003)","6":"Aprilia ETV1000 (2000 t\/m 2003)"[spam-filter],{"name":{"1":"Aprilia ETV1000 (2000 t\/m 2003)","2":"Aprilia ETV1000 (2000 t\/m 2003)","3":"Aprilia ETV1000 (2000 t\/m 2003)","4":"Aprilia ETV1000 (2000 t\/m 2003)","5":"Aprilia ETV1000 (2000 t\/m 2003)","6":"Aprilia ETV1000 (2000 t\/m 2003)"[spam-filter],{"name":{"1":"Aprilia ETV1000 (vanaf 2004)","2":"Aprilia ETV1000 (vanaf 2004)","3":"Aprilia ETV1000 (vanaf 2004)","4":"Aprilia ETV1000 (vanaf 2004)","5":"Aprilia ETV1000 (vanaf 2004)","6":"Aprilia ETV1000 (vanaf 2004)"[spam-filter],{"name":{"1":"Aprilia ETV1000 (vanaf 2004)","2":"Aprilia ETV1000 (vanaf 2004)","3":"Aprilia ETV1000 (vanaf 2004)","4":"Aprilia ETV1000 (vanaf 2004)","5":"Aprilia ETV1000 (vanaf 2004)","6":"Aprilia ETV1000 (vanaf 2004)"[spam-filter]]}

 

First of all, those are other brands, and second, shouldn't it be showing an array of id_products?

Link to comment
Share on other sites

..., and second, shouldn't it be showing an array of id_products?

It is in fact a jasonized array of (since we have left alone other params in the PHP) product name in the different languages

.

JASON or JSON is a representation of data 'in script'. If you declare an object or an array in javascript you do this king of syntax + human beautify/uglyfy. But you do exactly that.

Link to comment
Share on other sites

JASON or JSON is a representation of data 'in script'. If you declare an object or an array in javascript you do this king of syntax + human beautify/uglyfy. But you do exactly that.

to be honest, you kinda lost me on that one.

 

About the sql, without modifying it seems to work fine... as long as you put in a "bof" and "eof"

 

this is what happens if i put: make=Honda&model=CBR+900+RR&bof=1994&eof=1995

{"message":"More than one product match. Add more criteria","count":3,"rows":[{"name":{"1":"Lucas MST245","2":"Lucas MST245","3":"Lucas MST245","4":"Lucas MST245","5":"Lucas MST245","6":"Lucas MST245"[spam-filter],{"name":{"1":"Lucas MST245RAC","2":"Lucas MST245RAC","3":"Lucas MST245RAC","4":"Lucas MST245RAC","5":"Lucas MST245RAC","6":"Lucas MST245RAC"[spam-filter],{"name":{"1":"Lucas MST245SL","2":"Lucas MST245SL","3":"Lucas MST245SL","4":"Lucas MST245SL","5":"Lucas MST245SL","6":"Lucas MST245SL"[spam-filter]]}

 

Only this is what happens if i put no bof and eof so like: make=Honda&model=CBR+900+RR

{"message":"More than one product match. Add more criteria","count":15,"rows":[{"name":{"1":"Lucas MST245","2":"Lucas MST245","3":"Lucas MST245","4":"Lucas MST245","5":"Lucas MST245","6":"Lucas MST245"[spam-filter],{"name":{"1":"Lucas MST245","2":"Lucas MST245","3":"Lucas MST245","4":"Lucas MST245","5":"Lucas MST245","6":"Lucas MST245"[spam-filter],{"name":{"1":"Lucas MST245","2":"Lucas MST245","3":"Lucas MST245","4":"Lucas MST245","5":"Lucas MST245","6":"Lucas MST245"[spam-filter],{"name":{"1":"Lucas MST245","2":"Lucas MST245","3":"Lucas MST245","4":"Lucas MST245","5":"Lucas MST245","6":"Lucas MST245"[spam-filter],{"name":{"1":"Lucas MST245","2":"Lucas MST245","3":"Lucas MST245","4":"Lucas MST245","5":"Lucas MST245","6":"Lucas MST245"[spam-filter],{"name":{"1":"Lucas MST245RAC","2":"Lucas MST245RAC","3":"Lucas MST245RAC","4":"Lucas MST245RAC","5":"Lucas MST245RAC","6":"Lucas MST245RAC"[spam-filter],{"name":{"1":"Lucas MST245RAC","2":"Lucas MST245RAC","3":"Lucas MST245RAC","4":"Lucas MST245RAC","5":"Lucas MST245RAC","6":"Lucas MST245RAC"[spam-filter],{"name":{"1":"Lucas MST245RAC","2":"Lucas MST245RAC","3":"Lucas MST245RAC","4":"Lucas MST245RAC","5":"Lucas MST245RAC","6":"Lucas MST245RAC"[spam-filter],{"name":{"1":"Lucas MST245RAC","2":"Lucas MST245RAC","3":"Lucas MST245RAC","4":"Lucas MST245RAC","5":"Lucas MST245RAC","6":"Lucas MST245RAC"[spam-filter],{"name":{"1":"Lucas MST245RAC","2":"Lucas MST245RAC","3":"Lucas MST245RAC","4":"Lucas MST245RAC","5":"Lucas MST245RAC","6":"Lucas MST245RAC"[spam-filter],{"name":{"1":"Lucas MST245SL","2":"Lucas MST245SL","3":"Lucas MST245SL","4":"Lucas MST245SL","5":"Lucas MST245SL","6":"Lucas MST245SL"[spam-filter],{"name":{"1":"Lucas MST245SL","2":"Lucas MST245SL","3":"Lucas MST245SL","4":"Lucas MST245SL","5":"Lucas MST245SL","6":"Lucas MST245SL"[spam-filter],{"name":{"1":"Lucas MST245SL","2":"Lucas MST245SL","3":"Lucas MST245SL","4":"Lucas MST245SL","5":"Lucas MST245SL","6":"Lucas MST245SL"[spam-filter],{"name":{"1":"Lucas MST245SL","2":"Lucas MST245SL","3":"Lucas MST245SL","4":"Lucas MST245SL","5":"Lucas MST245SL","6":"Lucas MST245SL"[spam-filter],{"name":{"1":"Lucas MST245SL","2":"Lucas MST245SL","3":"Lucas MST245SL","4":"Lucas MST245SL","5":"Lucas MST245SL","6":"Lucas MST245SL"[spam-filter]]}

 

is that right???

Link to comment
Share on other sites

I can't tell, I know nothing about your catalog... if you omit the bof+eof it just does filter for the date ...

It will find either product for a CBR 1950 or a CBR 2011 ... (yes I know the 1950 one's does not exist).

 

What would be nice is that you implement the &year which make the query to use bof/eof

 

BTW how do you handle that bikes that are still in production?

Link to comment
Share on other sites

Btw, this is wat zen cart does with the original code.

 

This script that makes the 3 dropdown directs you to a page with the follow url:

index.php?main_page=product_filter_result&Make=Honda&Model=CBR+900+RR&Year=1994

 

As soon as that page loads, the script in the attachment reads the url and make the query of it

 

(at the end the $YMM_where can be used in other querys)

This probably gives you a better insight of what the original script does

 

application_top.php

 

If you go to http://www.motocc.nl/motorfilter you see the script in action.

Like you will see, if you only select make, you get all the product for that make (no mather what model or year)

Same with model, if you only select make+model, it will show all products for that selection (no mather what year)

Edited by MotoCCnl (see edit history)
Link to comment
Share on other sites

i tried changing the code to:

 

 $sql = 'SELECT products_id AS id_product FROM `'._DB_PREFIX_.'products_ymm` WHERE 1';
 if(isset($make))
  $sql .= " (products_car_make='".pSQL($make)."') ";
  if(isset($model))
  $sql .= ($sql != '' ? ' and ' : '') . " (products_car_model='".pSQL($model)."') ";
  if(isset($bof))
  $sql .= ($sql != '' ? ' and ' : '') . " ((products_car_year_bof <= '".pSQL($bof)."') ";
  if(isset($eof))
  $sql .= ($sql != '' ? ' and ' : '') . " ((products_car_year_bof <= '".pSQL($eof)."') ";

 

but that didn't work at all.

 

Yes.

1/ I have generated the variables $make,$mode, ... with Tools::getValue() they are all set. Only check the for empty

2/ $sql is already populated with a query all you need to do is add "AND clause" (spot the WHERE 1?)

Link to comment
Share on other sites

yes

 

Ok 2 minor bug from yesterday $value rather than $field_value

 

The ajaxCall

The template for the lateral display

 

You run that and it run like a snail because got the head upside down yesterday... Not that easy to make something in allocating 5mn every hour...

 

 

I'll prepare the javascript for next session...

As you mentionned you don't quite understand ajax, put it that way. we have two programs one generate the selector (combo), then we have a second program that use a parameter to generate a list

Then ajax: we organise in such way that the name of the selector coincide with the name of the parameter and we inject a little javascript that says to the first, pass that to the second

 

At that point ajax is done. However what we (web user) call ajax includes the next step which is have the list from the second program to interact with the first one this is pure javascript at that point or more to say DHTML.

 

PS: rename partsfilterbox.tpl.php in partsfitlerbox.tpl

partsfilter.php

partsfilterbox.tpl.php

Link to comment
Share on other sites

Ok, i tested the code and this is how it shows:

Schermafdruk.png

 

Is there a possibility to show only 1 year box? So that the customer can select the year he needs. For example mt own motorcycle is a honda cx500, there build between 1979 an 1986 but my motorcycle is a 1980 build. So instead of putting 1979 as bof and 1986 as eof i only want to put 1980 as year.

 

you asked me to make the query, but i can't get it to work, i know the final query should become:

SELECT products_id AS id_product

FROM `'._DB_PREFIX_.'products_ymm`

WHERE (`products_car_make`='Honda' or products_car_make='')

AND (`products_car_model`='CX+500' or products_car_model='')

AND ((`products_car_year_bof` <= '1980' and `products_car_year_eof` >= '1980"') or (products_car_year_bof=0 and products_car_year_eof=0))

 

like you see i used my own motorcycle as example with the year 1980

Link to comment
Share on other sites

I propose to continue with a text box as the year... what do you think

What do you prefer external javascript or in code (tpl)

I have a preference for external

 

A little change for perf ... yes it sound a step backward in the display but this is only due we miss automation - comes tomorrow ...

Link to comment
Share on other sites

SELECT products_id AS id_product

FROM `'._DB_PREFIX_.'products_ymm`

WHERE (`products_car_make`='Honda' or products_car_make='')

AND (`products_car_model`='CX+500' or products_car_model='')

AND ((`products_car_year_bof` <= '1980' and `products_car_year_eof` >= '1980"') or (products_car_year_bof=0 and products_car_year_eof=0))

 

I don't quite understand the (OR) for make/model. Do you have product targeting a all brand(make)?

 

I would have write WHERE 1

AND `products_car_make`='Honda'

AND `products_car_model`='CX+500' // Be carefull of the + here shouldl become space I guess

AND ( `products_car_year_bof` = 0 OR `products_car_year_bof` <= '1980' )

AND ( `products_car_year_eof` = 0 OR `products_car_year_eof` >= '1980')

// We will have to cast in integer to make thing clean

 

You'll be a master in LISP (a language geek calls Lots of Insipid and Stupid Parenthesis) :D

Edited by doekia (see edit history)
Link to comment
Share on other sites

I don't quite understand the (OR) for make/model. Do you have product targeting a all brand(make)?

 

I guess the (or) for the make can be taken out of it (as i always fill the make field to clarify for the customer)

Butt the (or) foor model has to stay, i sell products that can be used on all motorcycle (think of general tools)

 

AND ( `products_car_year_eof` = 0 OR `products_car_year_eof` >= '1980')

// We will have to cast in integer to make thing clean

Not quite sure i understand what your saying there, butt i know this query gives me the results i want to show my customers

Link to comment
Share on other sites

Hi man,

 

Hope you've get some good time for Christmas.

 

I took some time in between gift unpacking to prepare for the next step. There is still some design flaww and the interface is not fully operational but we have ajax populating the options and some sort of logic...

 

I won't be available in the next couple of days - until the 4th... but since then you'll have the time to think of the selection scenarios... specialy regarding year ...

 

Happy new year

(d)oekia

partsfilter.zip

Link to comment
Share on other sites

  • 7 months later...

Hi ,

 

I know this topic was started a while ago, but thought I would check with someone here.

I have a very similar requirement and was wondering how successful a module like this was.

 

I am in the process of building a website which required filtering of Make, Model and Year.

In some cases I have products which are compatible for a certain Year of a certain model.

 

i.e "YXY Brake pads" fit a "Honda CRX250 (1999 - 2002)", a "Honda XYK500 (2003 - 2004)", a "Honda ZXR550 (2011 - 2012)"

 

The Navigation would be as follows:

  1. Select the category (i.e Brakes)
  2. Product filtering is displayed (because it is now in category view)
  3. Select the Make (list of products is reduced)
  4. Select Model (List of products is reduced)
  5. Select Year (List of products is reduced)

 

I would like this product to be available for any of the above combinations of bike. This is difficult I believe because the product is available for the years 1999, 2000, 2001, 2002, 2003, 2004, 2011 and 2012. However not always available for those years if you select a different model. I can only imagine that you would need to somehow combine a feature with another feature to create a combination of year, make and model? so that it can be filterable.

 

This product I am talking about actually has about 100 different combination of Make, model and year that it would be compatible for. But not all years are available for every make and model, so there needs to be some sort of combination feature available to create these. I may be wrong or "barking up the wrong tree" however im assuming that this would work in the same way as attributes whereby you create combinations (which are then also filterable). There would only be a single stock count for this product so attributes is not an option. Also I don't want to have attribute selection drop downs on the product page, The product just needs to be returned as a valid product under the search for Make, Model an Year.

 

This module should be independent of the Prestashop Multilevel Navigation as we may want to include a price filter, colour filter etc etc.

This module should also be independent of the attribute system as we will need to use that for varying types of a product.

 

The module should be scalable with future releases of the Prestashop software, should we want to upgrade the website.

 

The example above is only of a few different scenarios, they include:

 

Single part fits different models of same make of bike.

 

[part / product] fits [make] - [model] - [year]

 

i.e.

 

SPR305-368 fits KTM- 125 SX/EXC - (04-12)

SPR305-368 fits KTM - 144 SX - (07-12)

SPR305-368 fits KTM - 200 SX - (04-12)

SPR305-368 fits KTM - 250 SXF - (05-12)

etc

etc

 

 

Single part fits more than one brand of bike.

 

i.e.

 

FWB100 fits Suzuki - DRZ400E - (00-07)

FWB100 fits Kawasaki - KX 125 - 93-11

FWB100 fits Kawasaki - KLX400 - (03-08)

FWB100 fits Suzuki - DRZ400SM - (05-09)

etc

etc

 

Please feel free to ask me any questions about this. I have created a topic for this Job Offer here http://www.prestasho...g-combinations/

Edited by nzrobert (see edit history)
Link to comment
Share on other sites

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...