Cron Schedule not working for custom module - magento

I have a custom module which have two cron schedule. below is the code of module's config.xml
<?xml version="1.0"?>
<config>
<modules>
<Inchoo_Test>
<version>0.1.0</version>
</Inchoo_Test>
</modules>
<blocks>
<test>
<rewrite>
<test>Inchoo_Test_Block_List</test>
</rewrite>
</test>
</blocks>
<global>
<helpers>
<test>
<class>Inchoo_Test_Helper</class>
</test>
</helpers>
<models>
<test>
<class>Inchoo_Test_Model</class>
</test>
</models>
<resources>
<test_setup>
<setup>
<module>Inchoo_Test</module>
</setup>
<connection>
<use>core_setup</use>
</connection>
</test_setup>
<test_write>
<connection>
<use>core_write</use>
</connection>
</test_write>
<test_read>
<connection>
<use>core_read</use>
</connection>
</test_read>
</resources>
</global>
<crontab>
<jobs>
<test>
<schedule><cron_expr>10 00 * * *</cron_expr></schedule>
<run><model>test/cron::hello</model></run>
</test>
<productremove>
<schedule><cron_expr>50 23 * * *</cron_expr></schedule>
<run><model>test/cron::bye</model></run>
</productremove>
</jobs>
</crontab>
</config>
and i have setup cron.sh every day at 7:00 PM. cron.php i used log inside both methods. hello creates log whereas bye didn't create log. I have run that cron mannual from aoe_scheduler and productremove works fine from admin. can someone tell me the possible causes why productremove is getting skipped.
I am little bit confused in cron working too. If i setup cron at the time of 7:00pm every day so whether it will work before 7:00 Pm or it will work for all scheduler after 7:00 PM at same day. or it will work for both before and after 7:00 PM

the reason is a wrong cron configuration. Default magento cron.sh use to run every 5 minutes to catch up with scheduled tasks. Aoe scheduler even suggests to run itself every minute.
Take a look at Schedule->List View to see what happens with your cronjobs. If you run cron.sh only once per day you will see many tasks being "skipped"

Related

Book: "Getting Started with Magento Extension Development", sql migration script not executed

I have followed the same steps as mentioned in the Book, the key steps are:
create the resources setup configuration at <Module Directory>/etc/config.xml as follow:
<?xml version="1.0"?>
<config>
<global>
<modules>
<Foggyline_HappyHour>
<version>1.0.0.0</version>
</Foggyline_HappyHour>
</modules>
<!-- Some Other Configuration (Doesn't matter) -->
<resources>
<foggyline_happyhour_setup>
<setup>
<model>Foggyline_HappyHour</model>
</setup>
</foggyline_happyhour_setup>
</resources>
<!-- Some Other Configuration (Doesn't matter) -->
</global>
</config>
Create a the migration script at <Module Directory>/sql/foggyline_happyhour_setup/install-1.0.0.0.php with the following script:
<?php
// Just checking if the script is executed
echo 'Thank you for your help :)';
Load any pages and check if the page print the message.
Nope, it didn't print anything. The script didn't run at all.
How can we fix this?
:( Apparently there was a typo in the books ):
According to the official docs, the setup definition should be <module> instead of <model>. Thus:
<?xml version="1.0"?>
<config>
<global>
<!-- Some Other Configuration (Doesn't matter) -->
<resources>
<foggyline_happyhour_setup>
<setup>
<module>Foggyline_HappyHour</module>
</setup>
</foggyline_happyhour_setup>
</resources>
<!-- Some Other Configuration (Doesn't matter) -->
</global>
</config>
Now I can see the script executed. :)

magento install script 1.8.1

I'm trying to create a symply module for import country region and more in database.It's very simple but the data wasn't import.I can't figure why:
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Province_Italian>
<version>1.0.50</version>
</Province_Italian>
</modules>
<global>
<resources>
<province_italian_setup>
<setup>
<module>Province_Italian</module>
<class>Province_Italian_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</province_italian_setup>
<province_italian_write>
<connection>
<use>core_write</use>
</connection>
</province_italian_write>
<province_italian_read>
<connection>
<use>core_read</use>
</connection>
</province_italian_read>
</resources>
</global>
</config>
basic configuration file
and i had this folder structure with install script
Province/Italian/Model/Resource/Setup.php
data/province_italian_setup/data-install-x.x.x.php
and usually file in etc folder for configurazion config.xml
It' very simple ,the module is added because i've seen this reference in core_resource table, but seem that can't read installation file from data folder.
Where's mistake?
I'm going mad!
Thanks
"because i've seen this reference in core_resource"
Dalete that reference record from core_resource, delete cache, and try again
A couple of suggestions:
Make sure that have your module enabled, by having a file in app/etc/modules/Province_Italian.xml stating the following information:
<?xml version="1.0"?>
<config>
<modules>
<Province_Italian>
<active>true</active>
<codePool>local</codePool>
<depends><!-- Put your Module dependencies here --></depends>
</Province_Italian>
</modules>
</config>
The code of the module can be found in app/code/local/Province_Italian
The first install file matches the version number of the module. In this case that would be 1.0.50. So the filename must be
app/code/local/Province_Italian/data/province_italian_setup/data-install-10.0.50.php
Once the install script has ran, it cannot run again. Make sure that the code province_italian_setup is absent in the database table core_resource. This will trigger Magento to run the setup script.
Have logging (Mage::log(...)) in your datat install script to see it the script runs.
When you have no custom setup functionality, then the Province_Italian_Model_Resource_Setup.
I also noticed that the models is missing in your XML. Probably your need to add it. Based upon your description, you probably need (1) a model to to manipulate a datastore purely through PHP code, and (2) need a resource model to import the data into a custom database table.
<config>
<modules>
<Province_Italian>
<version>1.0.50</version>
</Province_Italian>
</modules>
<global>
<models>
<province_italian>
<class>Province_Italian_Model</class>
<resourceModel>province_italian_resource</resourceModel>
</province_italian>
<province_italian_resource>
<class>Province_Italian_Model_Resource</class>
<entities>
<!-- Put your entities here -->
</entities>
</province_italian_resource>
</models>
<resources>
<province_italian_setup>
<setup>
<module>Province_Italian</module>
<!-- <class>Province_Italian_Model_Resource_Setup</class> -->
</setup>
</province_italian_setup>
<province_italian_write>
<connection>
<use>core_write</use>
</connection>
</province_italian_write>
<province_italian_read>
<connection>
<use>core_read</use>
</connection>
</province_italian_read>
</resources>
</global>
I hope the above will help.

Magento finds module XML in one install, and not another

I've been working on a plugin for Magento, and I have one global block with no xml tags outside of it in my layout/name.xml file as such:
<block name="one.two.three" template="project/button.phtml" />
The idea is to be able to call getBlockHtml("one.two.three") anywhere and be able to see the beta.phtml. I got this working no problem.
To test through my plugin's installation process, I tried installing another magento from scratch. I installed my plugin into the same directories as the first and copied/pasted the getBlockHtml from my older install, and nothing appears (not even the template hint)! Adding default references didn't help.
It's obviously not detecting my xml files, though the adminhtml menu and the mysql install script both work. Any idea why this would be? And yes, I have cleared cache countless times.
Edit:
Both installations are version 1.7.0.2
Both of these installations are on the same computer, so their filesystems and casing are presumably identical. Is it ever the case when two on the same computer could differ in case sensitivity?
Installing plugin: We have a script that copies files into the Magento installation, which has been working so far with the first installation, and is what I have been doing with the second ins. To confirm, the entries and tables in the magento database are added when the files are copied over.
My layout is stored in a general layout folder: app/design/layout/projectEmbeds.xml. I realize this is not common convention but it was like this before I got to this project, and it was working so I didn't mess with it. I assume this decision was made so it would appear independent website theme.
Similarly, my plugin is stored in app/code/local/ -> Project/Embeds, which contains Blocks, controllers, etc, Helper, Model, and sql as it should.
The button.phtml in question is located in app/design/frontend/default/default/project
My config.xml file stored in etc in the above directory is as follows. Anything referencing Project_Banner is important and the Project_Embed one is almost entirely deprecated.
<config>
<modules>
<Project_Embeds>
<version>0.1.0</version>
</Project_Embeds>
</modules>
<frontend>
<routers>
<embeds>
<use>standard</use>
<args>
<module>Project_Embeds</module>
<frontName>embeds</frontName>
</args>
</embeds>
</routers>
<layout>
<updates>
<embeds>
<file>projectEmbeds.xml</file>
</embeds>
</updates>
</layout>
</frontend>
<global>
<resources>
<project_embed_setup>
<setup>
<module>Project_Embeds</module>
<class>Project_Embeds_Model_Mysql4_Setup</class>
</setup>
</project_embed_setup>
</resources>
<models>
<embeds>
<class>Project_Embeds_Model</class>
<resourceModel>embeds_mysql4</resourceModel>
</embeds>
<projectbanner>
<class>Project_Banner_Model</class>
<resourceModel>banner_mysql4</resourceModel>
</projectbanner>
<embeds_mysql4>
<class>Project_Embeds_Model_Mysql4</class>
<entities>
<embeds>
<table>project_embed</table>
</embeds>
<banner>
<table>project_banner</table>
</banner>
</entities>
</embeds_mysql4>
</models>
<resources>
<embeds_setup>
<setup>
<embeds>Project_Embeds</embeds>
</setup>
<connection>
<use>core_setup</use>
</connection>
</embeds_setup>
<embeds_write>
<connection>
<use>core_write</use>
</connection>
</embeds_write>
<embeds_read>
<connection>
<use>core_read</use>
</connection>
</embeds_read>
</resources>
<blocks>
<embeds>
<class>Project_Embeds_Block</class>
</embeds>
</blocks>
<helpers>
<embeds>
<class>Project_Embeds_Helper</class>
</embeds>
</helpers>
</global>
<admin>
<routers>
<thisprojectname>
<use>admin</use>
<args>
<module>Project_Embeds</module>
<frontName>project</frontName>
</args>
</thisprojectname>
</routers>
<!-- default admin design package and theme -->
<design>
<package>
<name>base</name>
</package>
<theme>
<default>default</default>
</theme>
</design>
</admin>
<adminhtml>
<menu>
<embeds translate="title" module="embeds">
<title>Project</title>
<sort_order>9999</sort_order>
<children>
<projectbanner module="embeds">
<title>Edit Coupon</title>
<sort_order>1</sort_order>
<action>embeds/adminhtml_banner</action>
</projectbanner>
</children>
</embeds>
</menu>
<layout>
<updates handle="index_settings">
<embeds>
<file>projectEmbeds.xml</file>
</embeds>
</updates>
</layout>
</config>
Try adding the projectEmbeds.xml file in your theme used i.e default i guess
So add in
/app/design/frontend/default/default/layout/
and call the block inside
<default></default>
Let me know if it helps..

Magento: why resource script doesn't install?

I took an example from here.
My folder structure is:
- Avq
- - Import
- - - ...
- - - etc
- - - - config.xml
- - - sql
- - - - avq_import_setup
- - - - - mysql4-install-0.1.0.php
My config.xml is:
<?xml version="1.0"?>
<config>
<modules>
<Avq_Import>
<version>1.0.0.1</version>
</Avq_Import>
</modules>
<global>
<resources>
<avq_import_setup>
<setup>
<module>Avq_Import</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</avq_import_setup>
<avq_import_write>
<connection>
<use>core_write</use>
</connection>
</avq_import_write>
<avq_import_read>
<connection>
<use>core_read</use>
</connection>
</avq_import_read>
</resources>
</global>
</config>
and mysql4-install-0.1.0.php code inside:
<?php
die("!");
$installer = $this;
//....
And I cannot even get "!".
Where is error could be here?
Is there any methods to debug xml config?
PS: I turned off cache, tured on my module and avq_import_setup is absent in the core_resource table.
You need 2 things to magento execute your setup, first inside one folder with the same name of the node in your case is avq_import_setup, so its be avq_import_setup/mysql4-install-x.x.x.php, look i put x.x.x on the file name, you must change it by the version of your module, in your case its 1.0.0.1, and your file is 0.1.0, its the second thing.
And to finish, this execute just 1 time, when magento record on database your module info its done no more then 1 time.
So, if you try install your module and dont run the setup file, probably the magento already register your module on db, and dont run anymore your setup. In this case you must go to 'core_resource' table, and find your module and remove it. Now you can try install again.

Rewrite sql module

Hi I'm trying to rewrite or extend all database update sql's files from core to local without success, until now I have:
CORE:
+core
+Mage
+Mymodule
+...
+etc
-config.xml
+sql
+mymodule_setup
-mysql4-install-0.1.0.php
-mysql4-install-0.1.0-0.1.1.php
-...
LOCAL:
+local
+Mage
+Mynamespace
+Mymodule
+...
+etc
-config.xml
+sql
+mymodule_setup
-mysql4-install-0.1.0.php
-mysql4-install-0.1.0-0.1.1.php
-...
So my question is to avoid problems when upgrading Magento how show I configure the config.xml in core and local, rewrite Block, Model, I did with success, but not for sql, until now I have:
LOCAL
<?xml version="1.0"?>
<config>
<modules>
<Mage_Mymodule>
<version>0.1.1</version>
</Mage_Mymodule>
</modules>
<global>
<resources>
<mynamespace_mymodule_setup>
<setup>
<module>Mynamespace_Mymodule</module>
<class>Mage_Mymodule_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</mynamespace_mymodule_setup>
</resources>
<models>
<Mymodule>
<rewrite>
<abc>Mynamespace_Mymodule_Model_Abc</abc>
</rewrite>
</Mymodule>
</models>
</global>
</config>
Thanks in advance for any help.
There's no way to override install/update scripts.
You have to:
1. Set dependency for your module, it must be installed last.
2. In your install script you may use anything.
You'd better use Varien_Db_Adapter_Pdo_Mysql methods.
I think the problem is that you've changed the class in the resource setup to a class that probably doesn't exist. Try :
<setup>
<module>Mynamespace_Mymodule</module>
<class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
You could make some hack, like in your setup class overwrite the protected method _getAvailableDbFiles and rewriting it using dirname(FILE) instead of Mage::getModuleDir (Mage_Core_Model_Resource_Setup~480)

Resources