sooi65 Posted March 2, 2010 Share Posted March 2, 2010 Good day to you all!I have the following data:group 1, the default groupgroup 1010, 25% reductiongroup 1020, 10% reductioncustomer A belongs to group 1010 only (and 1 ofcourse).category X is connected to both groups 1 and 1010 category Y is connected to group 1 and 1020.I expect customer A to get 0% reduction on products from category Y because he does not belong to group 1020 and 25% on products from category X (due to the membership of group 1010).But as I noticed, customer A gets 25% reduction on both categories.What am I doing wrong?Greetz,Sooi Link to comment Share on other sites More sharing options...
sooi65 Posted March 6, 2010 Author Share Posted March 6, 2010 SOLVED!I solved the problem myself.I added a function to the Group class to filter the groups which are common to categories and customersThe order it by reduction descending and you have the appropriate reduction for products from that category for a specific customer.For who is interested: static public function getProductReduction($id_product, $id_customer) { $result = Db::getInstance()->getRow(' SELECT g.`reduction` FROM `'._DB_PREFIX_.'group` g INNER JOIN `'._DB_PREFIX_.'customer_group` cug ON (cug.`id_group` = g.`id_group`) INNER JOIN `'._DB_PREFIX_.'category_group` cag ON (cag.`id_group` = g.`id_group`) INNER JOIN`'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cag.`id_category`) WHERE g.`reduction` > 0 AND cug.`id_customer` = '.intval($id_customer).' AND cp.`id_product` = '.intval($id_product).' ORDER BY g.`reduction` DESC'); return $result['reduction']; } The modify the file product.php (from the Prestashop base folder) by changing Group::getReduction(intval($cookie->id_customer)) into Group::getProductReduction(intval($product->id_product), intval($cookie->id_customer)) and classes\Product.php Group::getReduction($id_customer)) into Group::getProductReduction($id_product, $id_customer)) Link to comment Share on other sites More sharing options...
sooi65 Posted March 6, 2010 Author Share Posted March 6, 2010 How do I add SOLVED to the thread subject? Link to comment Share on other sites More sharing options...
rocky Posted March 7, 2010 Share Posted March 7, 2010 Click the EDIT button on your first post above, then add [sOLVED] to the front of the "Title" text field. Link to comment Share on other sites More sharing options...
HelenI Posted March 16, 2010 Share Posted March 16, 2010 Thanks for the tip, I ran into the same problem today Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now