0

I want to get magento home page url in outside magento file I have added below code in my custom file pdf.php

require_once("app/Mage.php");
Mage::app();
$connectionWrite   = Mage::getSingleton('core/resource')->getConnection('core_write');
$product['inv_ID'] = $inv_ID = $_GET['id']; // Get the inventory ID
$_product          = Mage::getModel('catalog/product')->load($inv_ID);
if ($_product->getShortDescription()) {
    $product['Ad_Line'] = $_product->getShortDescription();
    $product['price']   = $_product->getFinalPrice();
    $product['image']   = $_product->getImage();
    echo $url                = Mage::getBaseUrl()
    exit;
}

I am getting below output

http://localhost/xxxproject/pdf.php/

How can I get direct home page url like below without using $_SERVER

http://localhost/xxxproject/

1 Answer 1

2

Have you tried to get home page from Admin site?

$storeId = 10;
$homepage = Mage::getStoreConfig('web/secure/base_url', $storeId);

FULL SCRIPTS ARE

require_once 'app/Mage.php'; $app = Mage::app('admin'); $storeId = 10; $homepage = Mage::getStoreConfig('web/secure/base_url', $storeId); echo 'homepage' . $homepage;

1
  • Yes, It's working with some minor changes. Thanks Commented Mar 16, 2017 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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