Create cron job for every five minutes? - magento-1.9

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.

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

change plesk subscription expire date via API

how can i prolong plesk subscription expire date via XML RPC or REST?
in the following code i can create subrcription, but i want a way to change the expiration date after creation.
<webspace>
<add>
<gen_setup>
<name>{domainName}</name>
<owner-login>{username}</owner-login>
<ip_address>1.1.1.1</ip_address>
</gen_setup>
<hosting>
<vrt_hst>
<property>
<name>ftp_login</name>
<value>ftp_{ftpUsername}</value>
</property>
<property>
<name>ftp_password</name>
<value>{pass}</value>
</property>
<ip_address>1.1.1.1</ip_address>
</vrt_hst>
</hosting>
<plan-name>{plan}</plan-name>
</add>
</webspace>
You can get subscription properties which include experation date in UNIXTIME using the following request:
<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
<webspace>
<get>
<filter>
<name>example.com</name>
</filter>
<dataset>
<limits/>
</dataset>
</get>
</webspace>
</packet>
To set the expiration date, use:
<?xml version="1.0" encoding="UTF-8"?>
<packet version="1.6.7.0">
<webspace>
<set>
<filter>
<name>example.com</name>
</filter>
<values>
<limits>
<limit>
<name>expiration</name>
<value>1600000000</value>
</limit>
</limits>
</values>
</set>
</webspace>
</packet>
Where example.com is a subscription name, 1600000000 - expiration date in UNIXTIME.

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>

display category in a grouped product detail view magento

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.

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)