I've been trying for days now to get a rewritten model to function. but it doesn't work, I'm puzzled because all seems to be correct.
___Here's my config file : etek/advancednewslettercoupon/etc/config.xml
<global>
<models>
<advancednewslettercoupon>
<class>Etek_AdvancedNewsletterCoupon_Model</class>
</advancednewslettercoupon>
<advancednewsletter>
<rewrite>
<subscriber>Etek_AdvancedNewsletterCoupon_Model_Subscriber</subscriber>
<rewrite>
</advancednewsletter>
</models>
</global>
__the subscriber model: Etek/AdvancedNewsletterCoupon/Model/Subscriber.php
class Etek_AdvancedNewsletterCoupon_Model_Subscriber extends AW_Advancednewsletter_Model_Subscriber
{
_construct() {
var_dump('Etek Subscriber');die(get_class($this));
}
public function subscribe($email, $segments, $params = array())
{ echo"<pre>";die('Etek Subscriber');
}
___Etek_AdvancedNewsletterCoupon.xml
<?xml version="1.0"?>
<config>
<modules>
<Etek_AdvancedNewsletterCoupon>
<active>true</active>
<codePool>local</codePool>
<depends>
<AW_Advancednewsletter/>
</depends>
</Etek_AdvancedNewsletterCoupon>
</modules>
</config>
I found out that I forgot to close the tag of rewrite:
<rewrite>
<subscriber>Etek_AdvancedNewsletterCoupon_Model_Subscriber</subscriber>
</rewrite>
Now all seems to work fine :)
Related
I try to create small extension for displaying string in Product page Magento 1.9.2. So I did it using "community" code pool for effecting block (block name ="product.info") in catalog.xml layout but it did not work till. I think my code is right but I don't sure whether all relevant folders (Controller, helper, Observer) are included or not in my module(Dinod). Please any one can help me to create this extension by using "community" code pool in Magento 1.9.2.
I failed to get expected output by testing my extension using "community" code pool. But same extension structure work fine after using "core" code pool. So I stored my module(Dinod) inside "app/code/core/Mage" folder and that time worked properly.
This code structure does not generate any expected output through frontend (product page).
app/etc/modules/Jpdn_Dinod.xml
<config>
<modules>
<Jpdn_Dinod>
<active>true</active>
<codePool>community</codePool>
</Jpdn_Dinod>
</modules>
</config>
app/code/community/Jpdn/Dinod/etc/config.xml
<config>
<modules>
<Jpdn_Dinod>
<version>1.0.3</version>
</Jpdn_Dinod>
</modules>
<frontend>
<layout>
<updates>
<Jpdn_Dinod module="Jpdn_Dinod">
<file>jpdn_dinod.xml</file>
</Jpdn_Dinod>
</updates>
</layout>
</frontend>
<global>
<!-- adding block "Jpdn_Dinod_Block_Product_View" -->
<blocks>
<jpdn_dinod>
<class>Jpdn_Dinod_Block_Product_View</class>
</jpdn_dinod>
</blocks>
<!-- adding block "Jpdn_Dinod_Block_Product_View" -->
</global>
</config>
app/code/community/Jpdn/Dinod/Block/Product/View/dinod.php
class Jpdn_Dinod_Block_Product_View_Dinod extends Mage_Core_Block_Template
{
public function dinod_methodblock()
{
$name = "Informations from dinod_methodblock in Jpdn_Dinod";
return $name;
}
}
app/design/frontend/base/default/layout/jpdn_dinod.xml
<layout version="1.0.3">
<catalog_product_view>
<reference name="product.info">
<!--
<block type="dinod/product_view_dinod" name="mage.view.dinod" as="mage.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
-->
<block type="jpdn_dinod/product_view_dinod" name="jpdn.view.dinod" as="jpdn.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
</reference>
</catalog_product_view>
</layout>
app/design/frontend/base/default/template/dinod/product/view/dinod.phtml
<?php echo $this->dinod_methodblock(); ?>
Above code structure does not generate any expected output through frontend (product page).
After I created new block class file in "app/code/core/Mage" and edited code in template file as below so I got expected output without any error.
app/code/core/Mage/Dinod/Block/Product/View/dinod.php
class Mage_Dinod_Block_Product_View_Dinod extends Mage_Core_Block_Template
{
public function dinod_methodblock()
{
$name = "Informations from dinod_methodblock in Mage_Dinod";
return $name;
}
}
app/design/frontend/base/default/layout/jpdn_dinod.xml
<layout version="1.0.3">
<catalog_product_view>
<reference name="product.info">
<block type="dinod/product_view_dinod" name="mage.view.dinod" as="mage.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
<block type="jpdn_dinod/product_view_dinod" name="jpdn.view.dinod" as="jpdn.dinod" template="dinod/product/view/dinod.phtml">
<action method="addToParentGroup"><group>detailed_info</group></action>
<action method="setTitle" translate="value"><value>Dinodddd works</value></action>
</block>
</reference>
</catalog_product_view>
</layout>
But I want to get same output only using "community" code pool instead of using "core" code pool for effecting block (block name ="product.info") in catalog.xml layout.
Your block definition is wrong
<blocks>
<jpdn_dinod>
<class>Jpdn_Dinod_Block_Product_View</class>
</jpdn_dinod>
</blocks>
this is not how you should declare it. Remove product_view
<class>Jpdn_Dinod_Block</class>
this should be enough
I am new to Magento 1.9. I have my own custom API which read last modified Product stock and do some updates. I need to make this API run every five minutes . Please help.
Here i mentioned module.
create Stackoverflow_Cronshedule.xml under app\etc\modules\
<?xml version="1.0"?>
<config>
<modules>
<Stackoverflow_Cronshedule>
<active>true</active>
<codePool>local</codePool>
<version>0.1.0</version>
</Stackoverflow_Cronshedule>
</modules>
</config>
create etc.xml under app\code\local\Stackoverflow\Cronshedule\etc\
<?xml version="1.0"?>
<config>
<modules>
<Stackoverflow_Cronshedule>
<version>0.1.0</version>
</Stackoverflow_Cronshedule>
</modules>
<global>
<models>
<cronshedule>
<class>Stackoverflow_Cronshedule_Model</class>
<resourceModel>cronshedule_mysql4</resourceModel>
</cronshedule>
</models>
</global>
<crontab>
<jobs>
<cronshedule_lastmodifiedproduct>
<schedule><cron_expr>*/5 * * * *</cron_expr></schedule>
<run><model>cronshedule/cron::lastModifiedProduct</model></run>
</cronshedule_lastmodifiedproduct>
</jobs>
</crontab>
</config>
Create Cron.php file under app\code\local\Stackoverflow\Cronshedule\Model\
<?php
class Stackoverflow_Cronshedule_Model_Cron{
public function lastModifiedProduct(){
// update last modified product
}
}
At last, Set cron task for every minute in your cPanel for your /cron.php file.
So i am down to the last bit of my module and it's really annoying i can't get it to add a new column to the CMS_PAGE table.
This is what i have so far:
/app/code/local/Damian/CMS/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<damian_cms>
<version>0.1.0</version> <!-- Version of module -->
</damian_cms>
</modules>
<global>
<models>
<damian_cms>
<class>Damian_CMS_Model</class>
<resourceModel>cms_mysql4</resourceModel>
</damian_cms>
</models>
<events>
<adminhtml_cms_page_edit_tab_content_prepare_form>
<observers>
<damian_page_edit_tab_content>
<type>singleton</type>
<class>Damian_CMS_Model_Observer</class>
<method>cmsField</method>
</damian_page_edit_tab_content>
</observers>
</adminhtml_cms_page_edit_tab_content_prepare_form>
<cms_page_prepare_save>
<observers>
<damian_cms_save_page>
<type>singleton</type>
<class>Damian_CMS_Model_Observer</class>
<method>savePage</method>
</damian_cms_save_page>
</observers>
</cms_page_prepare_save>
</events>
<resources>
<damian_cms_setup>
<setup>
<module>damian_cms</module>
<class>Damian_CMS_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</damian_cms_setup>
<cms_write> <!-- It gives the write permission to db -->
<connection>
<use>core_write</use>
</connection>
</cms_write>
<cms_read> <!-- It gives the read permission from db -->
<connection>
<use>core_read</use>
</connection>
</cms_read>
</resources>
</global>
</config>
/app/code/local/Damian/CMS/Model/Resource/Setup.php
<?php
class Damian_CMS_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup {
}
/app/code/local/Damian/CMS/sql/cms_setup/mysql-install-0.1.0.php
<?php
$installer = $this;
/* #var $installer Mage_Core_Model_Resource_Setup */
echo 'Running This Upgrade:';
die("Exit for now");
$installer->startSetup();
$tableName = $installer->getTable('cms_page');
$installer->getConnection()->addColumn($tableName, 'cms_sitemap', array(
'nullable' => true,
'length' => 255,
'default' => 1,
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
'comment' => 'added from extension Damian CMS'
));
$installer->endSetup();
I haven't added the rest becuase it all seems to work, but i neeed this install script to work so i can put it into production on the live server, this is local and i have access to my own MYSQL database, But on the live servers i won't have access to the MYSQL database so i have to get this script to work.
Thanks for your help :)
ok so i got it to work!
I had to change the name of the module to match what i had to this
<modules>
<Damian_CmsUpdate> <!-- Name had to change to match folder name -->
<version>0.1</version>
</Damian_CmsUpdate>
</modules>
and then had to update the setup in the config.xml to this
<! -.....- >
<setup>
<module>Damian_CmsUpdate</module>
<class>Damian_CmsUpdate_Model_Resource_Mysql4_Setup</class>
</setup>
<! -......- >
I'm currently using magento community. I have several grouped products. For example, I have cologne Polo Green, which is a grouped product. The products in that group are the 2.5oz; 3.4oz, 6.7oz, etc.
At the same time, I would like to add the category "After Shave" which will display the after shave products.
How can I add the category within the grouped product?
Thanks in advance.
Try with below custom module
1) config.xml
<?xml version="1.0"?>
<config>
<modules>
<NameSpace_YourModulename>
<version>0.1.0</version>
</NameSpace_YourModulename>
</modules>
<adminhtml>
<events>
<catalog_product_save_after>
<observers>
<NameSpace_YourModulename_Product_Update>
<type>singleton</type>
<class>NameSpace_YourModulename_Model_Observer</class>
<method>customApplyCategoryToGrouped</method>
</NameSpace_YourModulename_Product_Update>
</observers>
</catalog_product_save_after>
</events>
</adminhtml>
<global>
<models>
<NameSpace_YourModulename>
<class>NameSpace_YourModulename_Model</class>
</NameSpace_YourModulename>
</models>
</global>
</config>
2) Observer.php file inside model
<?php
class NameSpace_YourModulename_Model_Observer
{
public function customApplyCategoryToGrouped(Varien_Event_Observer $observer)
{
$currentProduct = Mage::getModel('catalog/product')->load($observer->getProduct()->getId());
$categoryIds = $currentProduct->getCategoryIds();
if($currentProduct->getTypeId() == 'grouped')
$simpleProducts = $currentProduct->getTypeInstance(true)->getAssociatedProducts($currentProduct);
if(count($simpleProducts) > 0)
foreach ($simpleProducts as $item) {
$_simplePro = Mage::getModel('catalog/product')->load($item->getId());
$_simplePro->setCategoryIds($categoryIds);
$_simplePro->save();
unset($_simplePro);
}
}
}
3 ) etc/modules/NameSpace_YourModulename.xml
<?xml version="1.0"?>
<config>
<modules>
<NameSpace_YourModulename>
<active>true</active>
<codePool>local</codePool>
</NameSpace_YourModulename>
</modules>
</config>
Hope this will help you..
So far I have the following, please correct if I am wrong
The first section goes to config at...
app>code>local>Myfile>Pt003(myfile)>etc = config.xml
The second goes to...
app>code>mage>persistent>model = Observer.php
The third is a given...
Thanks for the reply.
Following Alan Storm Tutorial in Custom Magento System Configuration, When i tried adding
the Data.php in the helper folder i still get this error:
Fatal error: Class 'Mage_Helloworld_Helper_Data' not found in E:\xampp\htdocs\magento
\app\Mage.php on line 520
**Alanstormdotcom\Helloworld\Helper\Data.php**
<?php
class Alanstormdotcom_Helloworld_Helper_Data extends Mage_Core_Helper_Abstract
{
}
**Alanstormdotcom\Helloworld\etc\system.xml**
<?xml version="1.0"?>
<config>
<tabs>
<helloconfig translate="label" module="helloworld">
<label>Hello Config</label>
<sort_order>99999</sort_order>
</helloconfig>
</tabs>
</config>
**Alanstormdotcom\Helloworld\etc\config.xml**
<?xml version="1.0"?>
<config>
<modules>
<Alanstormdotcom_Helloworld>
<version>0.1.0</version>
</Alanstormdotcom_Helloworld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Alanstormdotcom_Helloworld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
<global>
<helpers>
<class>Alanstormdotcom_Helloworld_Helper</class>
</helpers>
</global>
</config>
I just wanted to learn.. I know this works in you but still help me find why.. i might miss
something.. Thank you.
This bit is wrong:
<global>
<helpers>
<class>Alanstormdotcom_Helloworld_Helper</class>
</helpers>
</global>
It should be:
<global>
<helpers>
<helloworld>
<class>Alanstormdotcom_Helloworld_Helper</class>
</helloworld>
</helpers>
</global>
(The <helloworld> tag corresponds to module="helloworld" above)