Magento放弃了购物车通知

时间:2016-11-26 13:46:13

标签: php magento cron

如果购物车被拖了7天并且处于非活动状态,我正在尝试为废弃的购物车构建一个自动电子邮件通知程序。

我已将配置添加到: 应用程序/代码/核心/法师/销售的/ etc / config.php中

<crontab>
    <jobs>
        <sales_clean_quotes>
            <schedule>
                <cron_expr>0 0 * * *</cron_expr>
            </schedule>
            <run>
                <model>sales/observer::cleanExpiredQuotes</model>
            </run>
        </sales_clean_quotes>
    <notify_abondoned_quotes>
        <schedule>
            <cron_expr>*/1 * * * *</cron_expr>
        </schedule>
        <run>
            <model>sales/observer::notifyAbondonedQuotes</model>
        </run>
    </notify_abondoned_quotes>

和一个函数: 应用程序/代码/核心/法师/销售/型号/ Observer.xml

    public function notifyAbondonedQuotes()
{

    Mage::dispatchEvent('clear_expired_quotes_before', array('sales_observer' => $this));

    $lifetimes = ['1'=>1];

    foreach ($lifetimes as $storeId=>$lifetime) {
        $lifetime *= 604800;

        // @var $quotes Mage_Sales_Model_Mysql4_Quote_Collection 
        $quotes = Mage::getModel('sales/quote')->getCollection();

        $quotes->addFieldToFilter('store_id', $storeId);
        $quotes->addFieldToFilter('updated_at', array('to'=>date("Y-m-d H:i:s",time()-$lifetime)));
        $quotes->addFieldToFilter('is_active', 0);
    $customer_email = $quote->getCustomerEmail();   

    # Authenticate with your API key
    $auth = array('api_key' => 'xxxxxxxxx);

    # The unique identifier for this smart email
    $smart_email_id = 'xxxx-6464-4d80-8ece-3d83c7bax12dd';

    # Create a new mailer and define your message
    $wrap = new CS_REST_Transactional_SmartEmail($smart_email_id, $auth);
    $message = array(
        "To" => $customer_email.'<'.customer_email.'>',
        "Data" => array(
        'x-apple-data-detectors' => 'x-apple-data-detectorsTestValue',
        'href^="tel"' => 'href^="tel"TestValue',
        'href^="sms"' => 'href^="sms"TestValue',
        'owa' => 'owaTestValue',
        ),
    );

    # Send the message and save the response
    $result = $wrap->send($message);
    }
    return $this;
}

以上设置不起作用。请帮助。

0 个答案:

没有答案