How do I get a full Magento session in an external script? (Specifically, Catalog Rules)

Posted by Laizer on Stack Overflow See other posts from Stack Overflow or by Laizer
Published on 2010-05-12T09:29:52Z Indexed on 2010/05/12 9:34 UTC
Read the original article Hit count: 323

Filed under:

I'm running an external script that loads up a Magento session.

Within that script, I'm loading products and grabbing a bunch of properties. The one issue is that getFinalPrice() does not apply the catalog rules that apply to the product.

I'm doing everything I know to set the session, even a bunch of stuff that I think is superfluous. Nothing seems to get these rules applied.

Here's a test script:

require_once "app/Mage.php";
umask(0);
$app = Mage::app("default");

$app->getTranslator()->init('frontend');  //Probably not needed
Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton("customer/session");
$session->start();  //Probably not needed
$session->loginById(122);

$product = Mage::getModel('catalog/product')->load(1429);
echo $product->getFinalPrice();

Any insight is appreciated.

© Stack Overflow or respective owner

Related posts about magento