I need to run some Magento code from PHP file in nearby directory. So I created a file, lets call it test.php
:
include_once '/var/www/html/app/Mage.php';
umask(0);
Mage::app();
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', 'some-sku-123');
echo $product->getProductUrl();
When I open it from browser correct product URL is printed - http://example.com/product123.html
.
But when I execute this PHP file from command line via php path/to/test.php
, such URL is printed: test.php/product123.html
.
What's even more strange, is that previously it was working correctly, and I can't find what change did I make.
So my question is how to make sure that correct URL is printed when executed from command line?
Thank you.
edit: Mage::getBaseUrl()
also returns incorrect value - test.php/
.