display category in a grouped product detail view magento - html

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.

Related

Magento 1.9.4 Third party model override doesn't work

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 :)

Create cron job for every five minutes?

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.

add new column to install script in magento CMS Page

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>
<! -......- >

Magento 1.9 :: Custom Module Admin Menu Not Displaying Items

I have an issue on Magento 1.9.
I've just created a custom admin module, but menu items don't appear.
app/etc/modules/Pluma_Storico.xml
<?xml version="1.0" ?>
<config>
<modules>
<Pluma_Storico>
<active>true</active>
<codePool>local</codePool>
</Pluma_Storico>
</modules>
</config>
app/code/local/Pluma/Storico/etc/config.xml
<?xml version="1.0" ?>
<config>
<modules>
<Pluma_Storico>
<version>0.1.0</version>
</Pluma_Storico>
</modules>
</config>
app/code/local/Pluma/Storico/etc/adminhtml.xml
<?xml version="1.0" ?>
<config>
<menu>
<sales>
<children>
<storico module="pluma_storico">
<title>Storico</title>
<sort_order>10</sort_order>
<action>adminhtml/storico/index</action>
</storico>
</children>
</sales>
</menu>
</config>

Adding Data.php Helper in Magento got error

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)