News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Retrieve prices based on supplied shopper group

Started by RolandD, January 01, 2015, 14:10:04 PM

Previous topic - Next topic

RolandD

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]
Regards,

RolandD

CSVI
http://www.csvimproved.com/

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

RolandD

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]
Regards,

RolandD

CSVI
http://www.csvimproved.com/

Milbo

use VmConfig::loadConfig(); before you use the Vm API
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

RolandD

Regards,

RolandD

CSVI
http://www.csvimproved.com/