Author Topic: Bug: Product Price Maintenance when Vendors used  (Read 2760 times)

doorknob

  • Jr. Member
  • **
  • Posts: 151
Bug: Product Price Maintenance when Vendors used
« on: October 24, 2008, 21:37:35 pm »
I have been using the Vendor feature to segment my products and found that previously entered prices have become deleted. I tracked the cause down to the way that the product maintenance form is populated with existing prices.

When a vendor is added, a 'default' shopper group record is added which is supposed to be linked to the new vendor but the vendor_id is omitted so that the new vendor is left without any link to a shopper group. When a price is added to a product, it is linked to the default shopper group for vendor 1. When the same product is reloaded into the product maintenance page, it looks in the wrong place for the price and assumes that none exists. If the product details are saved without re-entering the price, the price record is deleted because the program assumes that the user wishes to delete the price.

I didn't want to get into vendor maintenance and so I have implemented a bodge of a fix which might help anyone with the same issue:
In the function get_retail_price() (in classes/ps_product), I replaced all three initial queries with the following that hard-codes the vendor_id as '1' (why not a single query anyway?)
Code: [Select]
$db = new ps_DB;
// Get the vendor id for this product.
//$q = "SELECT vendor_id FROM #__{vm}_product WHERE product_id='$product_id'";
//$db->setQuery($q); $db->query();
//$db->next_record();
//$vendor_id = $db->f("vendor_id");

// Get the default shopper group id for this product and user
//$q = "SELECT shopper_group_id FROM #__{vm}_shopper_group WHERE `vendor_id`='$vendor_id' AND `default`='1'";
//$db->setQuery($q); $db->query();
//$db->next_record();
//$default_shopper_group_id = $db->f("shopper_group_id");

//$q = "SELECT product_price,product_currency,price_quantity_start,price_quantity_end
// FROM #__{vm}_product_price
// WHERE product_id='$product_id' AND
// shopper_group_id='$default_shopper_group_id'";

// The software for maintaining vendor pricing does not work and so a default value of 1 is used so that
// prices previously saved can be retrieved
// In addition, the extraction is done with a single query to improve efficiency
$q = "SELECT product_price,product_currency,price_quantity_start,price_quantity_end
FROM #__{vm}_product_price AS price
JOIN #__{vm}_shopper_group AS shopper ON price.shopper_group_id=shopper.shopper_group_id
WHERE price.product_id='$product_id'
AND shopper.vendor_id='1'
AND shopper.`default`='1'";
$db->query($q);
Regards
Phil

arabbetts

  • Beginner
  • *
  • Posts: 1
Re: Bug: Product Price Maintenance when Vendors used
« Reply #1 on: April 07, 2009, 15:41:49 pm »
You don't need to do this.

As long as you create an additional 'default' 'shopper group' for your new vendor then all your products will be created using this new shopper_group_id.

If you don't do this then all your products are saved with the vm 'default' shopper_group_id.

The shopper_group_id is saved against each product in the vm_product_price table.

Andy