Author Topic: Order products by a custom field  (Read 5247 times)

patben

  • Beginner
  • *
  • Posts: 46
Order products by a custom field
« on: May 15, 2013, 15:27:47 pm »
Hi

I want to order the products in one category by a custom field is that posible??

For example i want to order books whith a custom field that is the year of the book release

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1461
Re: Order products by a custom field
« Reply #1 on: May 15, 2013, 16:48:10 pm »
You need a filtering extension.
Look here: http://breakdesigns.net/extensions/custom-filters

patben

  • Beginner
  • *
  • Posts: 46
Re: Order products by a custom field
« Reply #2 on: May 15, 2013, 17:01:21 pm »
with custom filters can I sort products with a custom field????

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1461
Re: Order products by a custom field
« Reply #3 on: May 15, 2013, 18:24:55 pm »
oh sorry i thought you wanted to filter products by custom field.

To sort them by custom field i think that you should change the sql query in the category pages.
You can find it at the file: administrator\components\com_virtuemart\models\product.php

The function is the sortSearchListQuery

patben

  • Beginner
  • *
  • Posts: 46
Re: Order products by a custom field
« Reply #4 on: May 16, 2013, 15:59:43 pm »
I would be obliged if you give me a little more information, because I could not understand how to do what im ask.

Thank you

patben

  • Beginner
  • *
  • Posts: 46
Re: Order products by a custom field
« Reply #5 on: June 18, 2013, 22:52:46 pm »
any idea ?

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1461
Re: Order products by a custom field
« Reply #6 on: June 19, 2013, 11:14:51 am »
It needs some sql knowledge.
You should join the query with the product_customfields table of the database and then change the order by to 1 of the fields of this table

patben

  • Beginner
  • *
  • Posts: 46
Re: Order products by a custom field
« Reply #7 on: June 19, 2013, 16:37:31 pm »
I have to make changes in this file only, administrator\components\com_virtuemart\models\product.php ?

balai

  • 3rd party VirtueMart Developer
  • Full Member
  • *
  • Posts: 1461
Re: Order products by a custom field
« Reply #8 on: June 19, 2013, 16:42:36 pm »
If you want to have your products to be sorted only by a custom field yes this file is enough.
If you want to have other sorting options too, you should add the sort by custom field option also to the drop-down list that regrads the sorting

patben

  • Beginner
  • *
  • Posts: 46
Re: Order products by a custom field
« Reply #9 on: June 25, 2013, 15:44:58 pm »
i want i can choose sort by custom field in sort by page of settings of virtuemart but don't lost the other options of sort by. it is posible?