All this can be done using Magento, but as you
said, this is a very broad question. I'll give answers to the specific
topics, but I suggest you take time to study the fundamentals of Magento
module development. Here is an excellent tutorial by Alan Storm (read the whole series).
Instead of adding increments to a abandoned_duration attribute, I suggest simply checking against the
This XML registers a cronjob with Magento.
Get list of abandoned carts
In Magento, the cart is simply a wrapper for thesales/quote
object, so that is the entity you will be working with.Instead of adding increments to a abandoned_duration attribute, I suggest simply checking against the
updated_at
field.$adapter = Mage::getSingleton('core/resource')->getConnection('sales_read');
$minutes = 15;
$from = $adapter->getDateSubSql(
$adapter->quote(now()),
$minutes,
Varien_Db_Adapter_Interface::INTERVAL_MINUTE
);
$quotes = Mage::getResourceModel('sales/quote_collection')
->addFieldToFilter('converted_at', $adapter->getSuggestedZeroDate())
->addFieldToFilter('updated_at', array('to' => $from));
This will give you a collection (think of it as an array with
methods) of all quotes that haven't been updated for 15 minutes. You can
iterate over them like an array
foreach ($quotes as $quote) {
/* @var $quote Mage_Sales_Model_Quote */
}
Magento Cronjobs
In Magento, all cron jobs are listed in the configuration structure. So first you need to add it to the config.xml of your module (refer to the linked tutorial for more information on Magento configuration).This XML registers a cronjob with Magento.
*/15 * * * *
your_module/observer
and call the processAbandonedCarts()
method.In order for Magento to process configured cronjobs, you need to set the system up to do so. This consists of two parts: the system configuration and the triggering of the cron jobs.
The system configuration is done in the administrative interface under System > Configuration > System > Cron (Scheduled Tasks)
The triggering consists of setting up a way to periodically execute the cron.php (or cron.sh) script in the Magento root directory. This can be done using a regular crontab entry (
man 5 crontab
on any decent unix system for more information). Another option preferred by many is to execute the cron.php script through a curl
or wget
call so the processing user ID matches the regular Magento user ID
(i.e. the Apache user). This might be important if APC caching is
configured, but this is getting off topic.However, on topic is that you need to call it often enough so it matches the settings you specify in the administrative interface!
I generally recommend executing the cron.php script every 5 minutes. If there is nothing scheduled it will simply exit.
One really useful extension for Magento when working with cronjobs is Aoe_Scheduler. It adds much of the user interfaces for cronjobs and interactive functionality that should be part of the core system.
Other
Sending the data to a web service is not Magento specific, but rather regular PHP, so I'll wont go into more detail.To delete a cart, simple call
$quote->delete()
on the loaded sales/quote
instance.Please ask mor specific questions for further information.
http://stackoverflow.com/questions/9223790/where-to-start-with-magento-shopping-cart-abandonment
Related Link
http://www.magentocommerce.com/magento-connect/anatta-design-abandoned-carts-2536.html
Increase ecommerce conversion
ReplyDeleteYou are good bloger.Your writing quality is very nice, and i got so much to learn from your blog. It is in point of fact a great and helpful piece of information. I am glad that you simply shared this useful info with us.
Good work visvasolutions,
ReplyDeleteAfter using the above code, i faced an issue and that is: the Magento is not processing the configured cronjobs. I tried from the backend in systems configuration but still no success.
I also use another Magento Abandoned Cart Extension by FME which works fine in Magento 1.9. http://www.fmeextensions.com/magento-abandond-cart-reminder.html