Question

I have the following php code (running under magento 1.7.0.2) that finds a customer group with a particular code. The code works fine for groups that have no spaces in the code value, however it will not find any groups with a space in the code value, Can you locate the reason?

I don't want to change the code to use the group ID as this is not practical in this situation, can anyone help?

$theGrous = Mage::getModel('customer/group')->getCollection()->addFilter('customer_group_code', $groupName);

For example when the variable $groupName is 'Standard' I find results, when it is 'Standard Rate' I don't get it as it, this happens for any codes with spaces in them

thanks

Was it helpful?

Solution 2

thanks for looking into it, in the end I changed the code to iterate over collection and manually compare each code, and it still didn't work! Turns out that there was a slight difference in the names which for reason I didn't notice so the original filter was working correctly after all!

Thanks!

OTHER TIPS

This is another option to get customer group name.

$group = Mage::getModel('customer/customer_group')->load($groupId);
$group->getName();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top