php - Magento system.xml groups multiselect -
Menu-> configurate in the admin panel I have a tab I am using:
< Code> & lt; Frontend_type & gt; Multispack & lt; / Frontend_type & gt; & Lt; Source_model & gt; Adminhtml / system_config_source_customer_group_multiselect & lt; / Source_model & gt;And I get a three user group, i.e. a general, retail, whistle.
Question, how to get the fourth group, namely not logged in?
Instead of calling the core model, you can define your own supervisor in system.xml
Please find the code below which will solve your problem.
& lt; Source_model & gt; Adminhtml / system_config_source_groupCollection & lt; / Source_model & gt;
Now create your GroupCollection.php file in your local community (working directory) below.
For example, app \ code \ local \ Mage \ Adminhtml \ Model \ System \ Config \ Source \ GroupCollection.php
code below that file Add.
& lt; Php class Mage_Adminhtml_Model_System_Config_Source_GroupCollection {/ * * * option recipient * * return array * / public function toOptionArray () {$ group = Dana :: mill model ('customer / group') - & gt; GetCollection (); $ GroupArray = array (); Foreign exchange ($ group $ each group) {$ groupData = array ('client_group_id' = & gt; $ each group- & gt; getCustomerGroupId (), 'customer_group_code' = & gt; $ each group- & gt; GetCustomerGroupCode (), 'tax_class_id' = & gt; $ each group- & gt; getTaxClassId () // We do not need this); If (! $ GroupData) {array_push ($ groupArray, $ groupData); }} Var_dump ($ groupArray); }}
The following will be your output.
array (size = 4) 0 = & gt; Array (size = 3) 'customer_group_id' = & gt; String '0' (length = 1) 'customer_group_code' = & gt; String 'not logged in' (length = 13) 'tax_class_id' = & gt; String '3' (length = 1) 1 = & gt; Array (size = 3) 'customer_group_id' = & gt; String '1' (length = 1) 'customer_group_code' = & gt; String 'General' (length = 7) 'tax_class_id' = & gt; String '3' (length = 1) 2 = & gt; Array (size = 3) 'customer_group_id' = & gt; String '2' (length = 1) 'customer_group_code' = & gt; String 'bulk' (length = 9) 'tax_class_id' = & gt; String '3' (length = 1) 3 = & gt; Array (size = 3) 'customer_group_id' = & gt; String '3' (length = 1) 'customer_group_code' = & gt; String 'retailer' (length = 8) 'tax_class_id' = & gt; String '3' (length = 1)
And you have done it! :)
Comments
Post a Comment