My config.xml,
File Path: app/code/local/Namespace/Modulename/etc/config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Namespace_Modulename>
<version>0.0.1</version>
</Namespace_Modulename>
</modules>
<!-- Configure our module's behavior in the global scope -->
<frontend>
<routers>
<modulename>
<use>standard</use>
<args>
<module>Namespace_Modulename</module>
<frontName>modulename</frontName>
</args>
</modulename>
</routers>
</frontend>
<global>
<models>
<Namespace_Modulename>Namespace_Modulename_Model</Namespace_Modulename>
<Modulename>
<class>Namespace_Modulename_Model</class>
<resourceModel>Modulename_mysql4</resourceModel>
</Modulename>
<Modulename_mysql4>
<class>Namespace_Modulename_Model_Mysql4</class>
<entities>
<Modulename>
<table>modulename</table>
</Modulename>
</entities>
</Modulename_mysql4>
</models>
<resources>
<Modulename_setup>
<setup>
<module>Namespace_Modulename</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</Modulename_setup>
<Modulename_write>
<connection>
<use>core_write</use>
</connection>
</Modulename_write>
<Modulename_read>
<connection>
<use>core_read</use>
</connection>
</Modulename_read>
</resources>
<events>
<checkout_cart_product_add_after>
<observers>
<namespace_modulename_checkout_cart_product_add_after_observer>
<type>singleton</type>
<class>Namespace_Modulename_Model_Observer</class>
<method>onAddToCart</method>
</namespace_modulename_checkout_cart_product_add_after_observer>
</observers>
</checkout_cart_product_add_after>
</events>
</global>
</config>
My Observer.php
File Path: app/code/local/Namespace/Modulename/Model/Observer.php
<?php
class Namespace_Modulename_Model_Observer
{
public function onAddToCart(Varien_Event_Observer $observer)
{
$product = $observer->getEvent()->getProduct();
$name = $product->getName();
$sku = $product->getSku();
Mage::log(
"{$name} ({$sku}) updated",
null,
'product-updates.log'
);
}
}
Modulename.php, read filepath below,
File Path: app/code/local/Namespace/Modulename/Model/Mysql4/Modulename.php
<?php
class Namespace_Modulename_Model_Mysql4_Modulename extends Mage_Core_Model_Mysql4_Abstract
{
public function _construct()
{
$this->_init('modulename/modulename', 'modulename_id');
}
}
Collection.php, read filepath below,
File Path: app/code/local/Namespace/Modulename/Model/Mysql4/Modulename/Collection.php
<?php
class Namespace_Modulename_Model_Mysql4_Modulename_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
{
public function _construct()
{
//parent::__construct();
$this->_init('modulename/modulename');
}
}
mysql4-install-0.1.0.php, read filepath below,
File Path: app/code/local/Namespace/Modulename/sql/modulename_setup/mysql4-install-0.1.0.php
<?php
$installer = $this;
$installer->startSetup();
$installer->run("
-- DROP TABLE IF EXISTS {$this->getTable('modulename')};
CREATE TABLE {$this->getTable('modulename')} (
`modulename_id` int(11) unsigned NOT NULL auto_increment,
`title` varchar(255) NOT NULL default '',
`content` text NOT NULL default '',
`status` smallint(6) NOT NULL default '0',
`created_time` datetime NULL,
`update_time` datetime NULL,
PRIMARY KEY (`modulename_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->endSetup();
So these are all my available files for the extension Namespace_Modulename
.
It works perfectly alright with no errors, system.log does not show any error.
When I add to cart, the entry is successfully logged and event is triggered. So this proves that extension is working properly.
Magento configuration: Logs are enabled and cache is disabled.
My Problem:
As you can see my file mysql4-install-0.1.0.php
above, it has a query of create table, but it is not creating the table when I check the database, no table is created.
EDIT: List of all my tables: (You can see modulename table does not exist)
adminnotification_inbox
admin_assert
admin_role
admin_rule
admin_user
api2_acl_attribute
api2_acl_role
api2_acl_rule
api2_acl_user
api_assert
api_role
api_rule
api_session
api_user
captcha_log
cataloginventory_stock
cataloginventory_stock_item
cataloginventory_stock_status
cataloginventory_stock_status_idx
cataloginventory_stock_status_tmp
catalogrule
catalogrule_affected_product
catalogrule_customer_group
catalogrule_group_website
catalogrule_product
catalogrule_product_price
catalogrule_website
catalogsearch_fulltext
catalogsearch_query
catalogsearch_result
catalog_category_anc_categs_index_idx
catalog_category_anc_categs_index_tmp
catalog_category_anc_products_index_idx
catalog_category_anc_products_index_tmp
catalog_category_entity
catalog_category_entity_datetime
catalog_category_entity_decimal
catalog_category_entity_int
catalog_category_entity_text
catalog_category_entity_varchar
catalog_category_flat_store_1
catalog_category_product
catalog_category_product_index
catalog_category_product_index_enbl_idx
catalog_category_product_index_enbl_tmp
catalog_category_product_index_idx
catalog_category_product_index_tmp
catalog_compare_item
catalog_eav_attribute
catalog_product_bundle_option
catalog_product_bundle_option_value
catalog_product_bundle_price_index
catalog_product_bundle_selection
catalog_product_bundle_selection_price
catalog_product_bundle_stock_index
catalog_product_enabled_index
catalog_product_entity
catalog_product_entity_datetime
catalog_product_entity_decimal
catalog_product_entity_gallery
catalog_product_entity_group_price
catalog_product_entity_int
catalog_product_entity_media_gallery
catalog_product_entity_media_gallery_value
catalog_product_entity_text
catalog_product_entity_tier_price
catalog_product_entity_varchar
catalog_product_flat_1
catalog_product_index_eav
catalog_product_index_eav_decimal
catalog_product_index_eav_decimal_idx
catalog_product_index_eav_decimal_tmp
catalog_product_index_eav_idx
catalog_product_index_eav_tmp
catalog_product_index_group_price
catalog_product_index_price
catalog_product_index_price_bundle_idx
catalog_product_index_price_bundle_opt_idx
catalog_product_index_price_bundle_opt_tmp
catalog_product_index_price_bundle_sel_idx
catalog_product_index_price_bundle_sel_tmp
catalog_product_index_price_bundle_tmp
catalog_product_index_price_cfg_opt_agr_idx
catalog_product_index_price_cfg_opt_agr_tmp
catalog_product_index_price_cfg_opt_idx
catalog_product_index_price_cfg_opt_tmp
catalog_product_index_price_downlod_idx
catalog_product_index_price_downlod_tmp
catalog_product_index_price_final_idx
catalog_product_index_price_final_tmp
catalog_product_index_price_idx
catalog_product_index_price_opt_agr_idx
catalog_product_index_price_opt_agr_tmp
catalog_product_index_price_opt_idx
catalog_product_index_price_opt_tmp
catalog_product_index_price_tmp
catalog_product_index_tier_price
catalog_product_index_website
catalog_product_link
catalog_product_link_attribute
catalog_product_link_attribute_decimal
catalog_product_link_attribute_int
catalog_product_link_attribute_varchar
catalog_product_link_type
catalog_product_option
catalog_product_option_price
catalog_product_option_title
catalog_product_option_type_price
catalog_product_option_type_title
catalog_product_option_type_value
catalog_product_relation
catalog_product_super_attribute
catalog_product_super_attribute_label
catalog_product_super_attribute_pricing
catalog_product_super_link
catalog_product_website
checkout_agreement
checkout_agreement_store
cms_block
cms_block_store
cms_page
cms_page_store
core_cache
core_cache_option
core_cache_tag
core_config_data
core_email_queue
core_email_queue_recipients
core_email_template
core_flag
core_layout_link
core_layout_update
core_resource
core_session
core_store
core_store_group
core_translate
core_url_rewrite
core_variable
core_variable_value
core_website
coupon_aggregated
coupon_aggregated_order
coupon_aggregated_updated
cron_schedule
customer_address_entity
customer_address_entity_datetime
customer_address_entity_decimal
customer_address_entity_int
customer_address_entity_text
customer_address_entity_varchar
customer_eav_attribute
customer_eav_attribute_website
customer_entity
customer_entity_datetime
customer_entity_decimal
customer_entity_int
customer_entity_text
customer_entity_varchar
customer_form_attribute
customer_group
dataflow_batch
dataflow_batch_export
dataflow_batch_import
dataflow_import_data
dataflow_profile
dataflow_profile_history
dataflow_session
design_change
directory_country
directory_country_format
directory_country_region
directory_country_region_name
directory_currency_rate
downloadable_link
downloadable_link_price
downloadable_link_purchased
downloadable_link_purchased_item
downloadable_link_title
downloadable_sample
downloadable_sample_title
eav_attribute
eav_attribute_group
eav_attribute_label
eav_attribute_option
eav_attribute_option_value
eav_attribute_set
eav_entity
eav_entity_attribute
eav_entity_datetime
eav_entity_decimal
eav_entity_int
eav_entity_store
eav_entity_text
eav_entity_type
eav_entity_varchar
eav_form_element
eav_form_fieldset
eav_form_fieldset_label
eav_form_type
eav_form_type_entity
gift_message
importexport_importdata
index_event
index_process
index_process_event
log_customer
log_quote
log_summary
log_summary_type
log_url
log_url_info
log_visitor
log_visitor_info
log_visitor_online
newsletter_problem
newsletter_queue
newsletter_queue_link
newsletter_queue_store_link
newsletter_subscriber
newsletter_template
oauth_consumer
oauth_nonce
oauth_token
paypal_cert
paypal_payment_transaction
paypal_settlement_report
paypal_settlement_report_row
persistent_session
poll
poll_answer
poll_store
poll_vote
product_alert_price
product_alert_stock
rating
rating_entity
rating_option
rating_option_vote
rating_option_vote_aggregated
rating_store
rating_title
report_compared_product_index
report_event
report_event_types
report_viewed_product_aggregated_daily
report_viewed_product_aggregated_monthly
report_viewed_product_aggregated_yearly
report_viewed_product_index
review
Solutions tried:
-Cache refreshed (its disabled anyways)
-Changing version in config.xml to 0.1.0 and refreshing cache
-Renaming the version of mysql php file to 0.0.1 and refreshing cache
-Entry for "Modulename_setup" in the table core_resource deleted and then refreshed my homepage, it got created again but the table was still not created.
-Deleted "Modulename_setup" in the table core_resource and then inserted log in the mysql php file Mage::log('testing', null, 'install.log', true); and see if the file var/log/install.log
and refreshed the page, "Modulename_setup" reappeared, but no log file was created, the script didn't get executed.