News:

Looking for documentation? Take a look on our wiki

Main Menu

Add additional Available Sort-by Fields

Started by devteam, October 21, 2015, 18:56:31 PM

Previous topic - Next topic

devteam

Hi Team,

Joomla 3.4.4
VirtueMart 3.0.10
CSVI Pro - VirtueMart 6.2.0
VM Custom Filters Pro 2.2.11

I'm trying to figure out how I can add more Sort-by Fields under CONFIGURATION > Configuration > Product Order Settings > Available Sort-by fields

Specifically I'd like to put custom fields I've created in the list.

After searching a bit it's clear that I'll have to edit where the sort function is selecting available fields out of the database but it's still unclear where the function is located. Any help getting me started in the right direction is appreciated. I haven't found much (useful) info in the forum or documentation yet but I'll keep searching.

Thanks!

-------------------

*Update 1

I've found where I can make the custom fields appear: /administrator/components/com_virtuemart/helpers/shopfunctions.php around line 984 is a function called getValidProductFilterArray where I added the custom fields names to the filterArray variable inside.

Now I can select the fields under Available Sort-by fields in VirtueMart and see them in the Sort dropdown on the front end. But when I select a newly added field I don't see any result and there don't seem to be errors in the VM debug. I'll keep looking and respond when I getter closer to a solution. 

-------------------

*Update 2

Looks like because I was using VM Custom Filters Pro the SQL error was being suppressed. When I went back to the category view via com_virtuemart (just the regular category page) and sorted by one of the new fields I saw This error.

Unknown column 'p.Make' in 'order clause' SQL=SELECT SQL_CALC_FOUND_ROWS p.`virtuemart_product_id` FROM `DB_virtuemart_products` as p LEFT JOIN `DB_virtuemart_product_shoppergroups` as ps ON p.`virtuemart_product_id` = `ps`.`virtuemart_product_id` LEFT JOIN `DB_virtuemart_product_categories` as pc ON p.`virtuemart_product_id` = `pc`.`virtuemart_product_id` WHERE ( `pc`.`virtuemart_category_id` = 3 AND ( `ps`.`virtuemart_shoppergroup_id`= "2" OR `ps`.`virtuemart_shoppergroup_id` IS NULL ) AND p.`published`="1" ) group by p.`virtuemart_product_id` ORDER BY `p`.Make ASC LIMIT 0, 24

Clearly the custom filed I've chosen doesn't appear as a column in the viruemart_products table because it's not a standard field. At least I know now that simply adding the custom fields to shopfunctions.php got me that far. Now to think of how to join the custom fields and product tables and where to make the chnage. virtuemart_product_customfields is built quite differently.