Note that there are some explanatory texts on larger screens.

plurals
  1. POMagento Store config strange behavior during custom module installation
    primarykey
    data
    text
    <p>Is there some restrictions of access to store configuration during installation of custom module in Magento? Here is the problem</p> <p>I have an installation script:</p> <pre><code> &lt;?php $installer = $this; $installer-&gt;startSetup(); $installer-&gt;run(" DROP TABLE IF EXISTS {$this-&gt;getTable('userpaymentban')}; CREATE TABLE IF NOT EXISTS {$this-&gt;getTable('userpaymentban')} ( `ban_id` INT NOT NULL AUTO_INCREMENT , `user_id` INT NOT NULL , `paymentmethod_id` VARCHAR(200) NOT NULL , `store_id` INT NOT NULL , PRIMARY KEY (`ban_id`) ) ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_general_ci;"); $defaultNotBannedPaymentMethods = array(); $paymentMethods = Mage::getSingleton('payment/config')-&gt;getAllMethods(); </code></pre> <p>The query is OK, but last line causes of throwing some wierd thing:</p> <pre><code> Error in file: "/var/www/magentotest/magento161/app/code/local/Alpha/Userpaymentban/sql/userpaymentban_setup/mysql4-install-0.1.0.php" - Warning: Invalid argument supplied for foreach() in /var/www/magentotest/magento161/app/code/core/Mage/Payment/Model/Config.php on line 76 #0 /var/www/magentotest/magento161/app/code/core/Mage/Core/Model/Resource/Setup.php(645): Mage::exception('Mage_Core', 'Error in file: ...') #1 /var/www/magentotest/magento161/app/code/core/Mage/Core/Model/Resource/Setup.php(421): Mage_Core_Model_Resource_Setup-&gt;_modifyResourceDb('install', '', '0.1.0') #2 /var/www/magentotest/magento161/app/code/core/Mage/Core/Model/Resource/Setup.php(327): Mage_Core_Model_Resource_Setup-&gt;_installResourceDb('0.1.0') #3 /var/www/magentotest/magento161/app/code/core/Mage/Core/Model/Resource/Setup.php(235): Mage_Core_Model_Resource_Setup-&gt;applyUpdates() #4 /var/www/magentotest/magento161/app/code/core/Mage/Core/Model/App.php(412): Mage_Core_Model_Resource_Setup::applyAllUpdates() #5 /var/www/magentotest/magento161/app/code/core/Mage/Core/Model/App.php(338): Mage_Core_Model_App-&gt;_initModules() #6 /var/www/magentotest/magento161/app/Mage.php(640): Mage_Core_Model_App-&gt;run(Array) #7 /var/www/magentotest/magento161/index.php(80): Mage::run('', 'store') #8 {main} </code></pre> <p>The exception was thrown in <code>Mage_Payment_Model_Config</code> in code:</p> <pre><code> public function getAllMethods($store=null) { $methods = array(); $config = Mage::getStoreConfig('payment', $store); echo "&lt;pre&gt;"; var_dump($config); echo "&lt;/pre&gt;"; foreach ($config as $code =&gt; $methodConfig) { $data = $this-&gt;_getMethod($code, $methodConfig); if (false !== $data) { $methods[$code] = $data; } } return $methods; } </code></pre> <p>As you can see I am already added some debugging code, but all what I receive from that is just <code>NULL</code></p> <p>My Magento is OK (I think) because when I am using <code>Mage::getSingleton('payment/config')-&gt;getAllMethods()</code> out of module installation scope (in a file with imported <code>app/Mage.php</code>) I receive a nice list of all payment methods.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload