If you use UC VAT module to show all prices with a VAT, the value saved in database is without the VAT and it is added on display.

For example, you save a product with a price of 100 and vat 20%, it saves 80. User sees 100.

But because this is in database, apachesolr_ubercart ndexes the price without the VAT, making price facet unusable - user sees a product with a price of 100 in a result filtering 20-85 for example.

apachesolr_ubercart should check if there is a VAT module. I can produce a patch but the question is - should we alter the price during index phase (index with a VAT) or during search phase (construct a facet title "price from 50-150" with a real values "price [40 TO 80]" ?)

CommentFileSizeAuthor
#3 apachesolr_ubercart_price.patch1.09 KBmeba

Comments

meba’s picture

Maybe we should generalize a bit with price handlers...

meba’s picture

Which leads to obvious - alteration should happen during search result phase.

meba’s picture

Status: Active » Needs review
StatusFileSize
new1.09 KB

Found out that it's impossible to do (or not easy/not-hackish) this during search - we simply don't have all the required information available in 'facet_fields'.

Attaching a patch that does uc_price alteration during indexing phase. Might need update function to force reindexing of products, new file apachesolr_ubercart.install:

function apachesolr_ubercart_update_6001() {
 $ret = array();
 $types = module_invoke_all('product_types')
 $ret[] = update_sql("UPDATE {apachesolr_search_node} SET changed = %d WHERE nid IN (SELECT nid FROM {node} WHERE type IN (" . db_placeholders($types, 'text') . "))", time(), $types);
 return $ret;
}
nick_vh’s picture

Hmm interesting issue,

Thank you for creating the patch, i'm going to add it after some testing!

nick_vh’s picture

Assigned: Unassigned » nick_vh
Status: Needs review » Fixed

Tested and commited and added to the latest release

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nick_vh’s picture

Status: Closed (fixed) » Fixed

Fixed and closed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.