Hello all,
Here is me fulfilling a New Years resolution. Create a patch so we can export prices based on a supplied shopper group without needing a logged-in user.
The change is pretty straightforward, the method getProductSingle() gets an added parameter named $user_shoppergroups and a default value to true, this makes the method declaration look like this:
public function getProductSingle($virtuemart_product_id = null, $front = true, $quantity = 1, $withParent = false, $virtuemart_shoppergroup_ids = 0, $user_shoppergroups = true)
A little further down we prevent the code from overwriting the supplied shoppergroup IDs:
if ($user_shoppergroups)
{
$usermodel = VmModel::getModel('user');
$currentVMuser = $usermodel->getCurrentUser();
if (!is_array($currentVMuser->shopper_groups))
{
$virtuemart_shoppergroup_ids = (array)$currentVMuser->shopper_groups;
}
else
{
$virtuemart_shoppergroup_ids = $currentVMuser->shopper_groups;
}
}
Since the default value is true this code block will always as execute and as such it is backwards compatible.
It would be great to get this into 3.0.3 and we can make a lot of users happy :)
[attachment cleanup by admin]
We just chatted by skype, here the result
The block is already in line 1049 with an if check to the $virtuemart_shoppergroup_ids = 0 already. So the best fix is just to remove the block in line 1086 to 1092.
Then using another parameter than 0 prevents using the shoppergroup ids of the current user, so calling it with false or true should already work.
Hey Max,
I found another issue exporting the prices with the latest 3.0.3. Not sure what changed but when retrieving the prices at some point the vendor information is loaded but the language tag is not set. This results in a broken query.
Please find attached a patch which adds a sanity check to make sure there is a language for translatable tables. It is a small change starting from line 936 until line 941.
Thanks for your consideration.
[attachment cleanup by admin]
use VmConfig::loadConfig(); before you use the Vm API
Thanks, will give it a go.