开发者

Year / Make / Model Product search for Joomla / VirtueMart?

开发者 https://www.devze.com 2023-01-18 12:58 出处:网络
I am in the process of building an AutoParts Store using Joomla and VirtueMart.I was wondering if there was a way for the end user to search by Year, Make, Model of a car, and then have the correspond

I am in the process of building an AutoParts Store using Joomla and VirtueMart. I was wondering if there was a way for the end user to search by Year, Make, Model of a car, and then have the corresponding开发者_C百科 car parts be listed.

I realize this is pretty complex, and don't expect to have this solved with a simple quick fix, but any advice or a push in the right direction would be appreciated.

Thank you for your time.


I hate to be a wet blanket, but it's not that simple. The vast majority of auto parts have a one to many relationship with the cars it will potentially fit on. For example, Ford used the same oil filter on dozens of models over a 30+ year period, and that filter also fits a bunch of Chrysler applications. The first think you are going to need to do is put together a good Year/Make/Model table that lists all of the cars you will be selling parts for. That's actually a lot harder than it sounds because you also have to consider engine and in some cases depending on the parts, trim package and other important options.

The good news is that you only need to add one field to the VM products. The field should be a list of all the IDs for each year/make/model that the part fits on.

Doing a good year/make/model implementation is a pretty tall order, good luck!


This is what I would do:

  • Add these parameters to the virtuemart backend under the "Add product" form. You would have to add new columns to the database to support these. This fix is quite easy in fact.

You can do this by:

Add the form boxes to the product form in admin (administrator\components\com_virtuemart\html\product.product_form.php):

<tr class="row0"> 
  <td width="21%"><div style="text-align:right;font-weight:bold;">
    <div>Year:</div>
  </td>
  <td width="79%"> 
    <input type="text" class="inputbox"  name="year" value="<?php $db->sp("year"); ?>" size="2" maxlength="2" />
  </td>
</tr>

Then you need to make sure these values get inserted in the database. In file (administrator\components\com_virtuemart\classes\ps_product.php) around line 273 you will find something like this - add in the line which is not indented like the rest:

    $fields = array ( 'vendor_id' => $vendor_id,
                    'product_parent_id' => vmRequest::getInt('product_parent_id'),
                    'product_sku' => vmGet($d,'product_sku'),
                    'product_name' => vmGet($d,'product_name'),
        'year' => vmGet($d,'year'),
                    'product_desc' => vmRequest::getVar('product_desc', '', 'default', '', VMREQUEST_ALLOWHTML),
                    'product_s_desc' => vmRequest::getVar('product_s_desc', '', 'default', '', VMREQUEST_ALLOWHTML),
                    'product_thumb_image' => vmGet($d,'product_thumb_image'),
                    'product_full_image' => vmGet($d,'product_full_image'),
  • Then what you need to do is add a form into your browse page and create functions in ps_product.php and shop.browse.php, in admin/classes and admin/html respectively, in order to restrict the products you display on your browse page according to the search options. I won't go into the code on this as it's quite lengthy and personally I like to get paid for this type of work. You may also customise the Virtuemart search module, maybe that would be an easier option, but I have never used the search module before so I wouldn't know. Explore your options. Good luck!
0

精彩评论

暂无评论...
验证码 换一张
取 消