1

I want to send the product stock alert mail from outside magento app folder.

How will i access the email object for that outside magento?

I have already bootstrapped Mage.php file

$storeId = Mage::app()->getStore()->getId();
$templateId = 'product_stock_alert';

$emailTemplate = Mage::getModel('core/email_template')->loadByCode($templateId);
//$vars = array('user_name' => $userName, 'product_name' => $productName);
//$emailTemplate->getProcessedTemplate($vars);
$emailTemplate->setSenderEmail(Mage::getStoreConfig('trans_email/ident_general/email', $storeId));

$emailTemplate->setSenderName(Mage::getStoreConfig('trans_email/ident_general/name', $storeId));

    foreach ($emails as $email) {
        if (in_array($email['product_id'], $qty)) {
            $emailTemplate->send($email['email_id'],'Alvaro');
        }
    }

EDIT:Any clue at least where to start checking on this?

1

Try the below.... Mage::getModel('productalert/observer')->process(); is used for stock /price alert mail. If you want to only send product stock alert then use

Goto to app/code/core/Mage/ProductAlert/Model/Observer.php make processStock type protected to public...After that

$email = Mage::getModel('productalert/email');
Mage::getModel('productalert/observer')->_processStock($email);

See more it code goes to app/code/core/Mage/ProductAlert/Model/Observer.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.