I need to "debug"(basically see what's happening) inside the mysql4-install.php
, because I have some problems to retrieve/insert new values in the just created tables.
<?php
//Version 0.1.0
Mage::log('start', null, 'mysqlinstaller.log');
$installer=$this;
$installer->startSetup();
$installer->run("
DROP TABLE IF EXISTS `{$installer->getTable('country/product')}`;
CREATE TABLE `{$installer->getTable('country/product')}` (
`product_id` INT(11) unsigned NOT NULL,
`active` ENUM('0','1') NOT NULL DEFAULT '0',
`allowed` ENUM('0','1') NOT NULL DEFAULT '0',
`country` VARCHAR(255),
PRIMARY KEY (`product_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->run("
DROP TABLE IF EXISTS `{$installer->getTable('country/category')}`;
CREATE TABLE `{$installer->getTable('country/category')}` (
`category_id` INT(11) unsigned NOT NULL,
`active` ENUM('0','1') NOT NULL DEFAULT '0',
`allowed` ENUM('0','1') NOT NULL DEFAULT '0',
`country` VARCHAR(255),
PRIMARY KEY (`category_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$setup = new Mage_Core_Model_Config();
$setup->saveConfig('razorphyn/country/buttons', json_encode(array()), 'default', 0);
//NEED TO KNOW WHAT IS GOING FROM HERE
//Populate table country/product
$collection = Mage::getModel('catalog/product')->getCollection()->getAllIds();
foreach($collection as $res){
$data = array('product_id'=>$res,'active'=>0,'allowed'=>0,'country'=>'');
Mage::getModel('country/product')->setData($data)->save();
}
//Populate table country/catalog
$collection = Mage::getModel('catalog/category');
$catTree = $collection->getTreeModel()->load();
$catIds = $catTree->getCollection()->getAllIds();
foreach($catIds as $id){
$data = array('category_id'=>$id,'active'=>0,'allowed'=>0,'country'=>'');
Mage::getModel('country/category')->setData($data)->save();
}
//End
$installer->endSetup();
?>
My problem is that I can't insert new values, so I tried to see whats inside the arrays/objects with this:
Mage::log(print_r($collection, TRUE), null, 'mylogfile1.log');
but without success, it doesn't even create the file
config.xml
<?xml version="1.0"?>
<config>
<modules>
<Razorphyn_Country>
<version>0.1.0</version>
</Razorphyn_Country>
</modules>
<global>
<models>
<country>
<class>Razorphyn_Country_Model</class>
<resourceModel>country_mysql4</resourceModel>
</country>
<country_mysql4>
<class>Razorphyn_Country_Model_Mysql4</class>
<entities>
<product>
<table>razorphyn_country_product</table>
</product>
<category>
<table>razorphyn_country_category</table>
</category>
</entities>
</country_mysql4>
</models>
<resources>
<country_setup>
<setup>
<module>Razorphyn_Country</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</country_setup>
<country_write>
<connection>
<use>core_write</use>
</connection>
</country_write>
<country_read>
<connection>
<use>core_read</use>
</connection>
</country_read>
</resources>
<blocks>
<country>
<class>Razorphyn_Country_Block</class>
</country>
</blocks>
<helpers>
<country>
<class>Razorphyn_Country_Helper</class>
</country>
</helpers>
</global>
<adminhtml>
<events>
<catalog_product_save_after>
<observers>
<razorphyn_country_catalog_product_save_after>
<type>singleton</type>
<class>Razorphyn_Country_Model_Observer</class>
<method>saveProductAllowedCountry</method>
</razorphyn_country_catalog_product_save_after>
</observers>
</catalog_product_save_after>
</events>
<layout>
<updates>
<country>
<file>Razorphyn/country.xml</file>
</country>
</updates>
</layout>
</adminhtml>
<frontend>
<events>
<!-- Retrieve Country as soon as possible Event -->
<controller_front_init_before>
<observers>
<razorphyn_country_controller_front_init_before>
<type>singleton</type>
<class>Razorphyn_Country_Model_Observer</class>
<method>retrieveCountry</method>
</razorphyn_country_controller_front_init_before>
</observers>
</controller_front_init_before>
<!-- Page Rendering event -->
<core_block_abstract_to_html_after>
<observers>
<razorphyn_country_core_block_abstract_to_html_after>
<type>singleton</type>
<class>Razorphyn_Country_Model_Observer</class>
<method>checkMerchantable</method>
</razorphyn_country_core_block_abstract_to_html_after>
</observers>
</core_block_abstract_to_html_after>
<!-- Add to cart Event -->
<controller_action_predispatch_checkout_cart_add>
<observers>
<razorphyn_country_controller_action_predispatch_checkout_cart_add>
<class>Razorphyn_Country_Model_Observer</class>
<method>checkProductOnAdd</method>
</razorphyn_country_controller_action_predispatch_checkout_cart_add>
</observers>
</controller_action_predispatch_checkout_cart_add>
<!-- Events related to potential address change -->
<customer_address_save_after>
<observers>
<razorphyn_country_customer_address_save_after>
<type>singleton</type>
<class>Razorphyn_Country_Model_Observer</class>
<method>updateCartAddress</method>
</razorphyn_country_customer_address_save_after>
</observers>
</customer_address_save_after>
<customer_login>
<observers>
<razorphyn_country_customer_login>
<type>singleton</type>
<class>Razorphyn_Country_Model_Observer</class>
<method>updateCartAddress</method>
</razorphyn_country_customer_login>
</observers>
</customer_login>
<checkout_controller_onepage_save_shipping_method>
<observers>
<razorphyn_country_checkout_controller_onepage_save_shipping_method>
<type>singleton</type>
<class>Razorphyn_Country_Model_Observer</class>
<method>updateCartAddress</method>
</razorphyn_country_checkout_controller_onepage_save_shipping_method>
</observers>
</checkout_controller_onepage_save_shipping_method>
<!-- Add js config -->
<core_block_abstract_to_html_before>
<observers>
<razorphyn_country_controller_action_predispatch_checkout_cart_add>
<class>Razorphyn_Country_Model_Observer</class>
<method>addConfigJs</method>
</razorphyn_country_controller_action_predispatch_checkout_cart_add>
</observers>
</core_block_abstract_to_html_before>
</events>
<layout>
<updates>
<country>
<file>Razorphyn/country.xml</file>
</country>
</updates>
</layout>
</frontend>
</config>
echo 'exiting'; die;
at the beginning of your script and show us your<resources>
node inconfig.xml
.config.xml
, I will add the code at the beginning of the php, is it necessary even if I know that the install is called (since the table are added andcore_resource
display my setup entryMage::getModel('country/product')
. Your new model might not be set up correctly, and it may not be an issue with the installation script. I suggest you run an independent script to test your model saves.