Magento 1 – Calling Magento Module Class from External PHP File

module

i have module in my magento

1: config.xml
code of config.xml:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <global>
        <helpers>
            <catalog>
                <rewrite>
                    <product_view>Inic_Catalog_Helper_Product_View</product_view>
                </rewrite>
            </catalog>
        </helpers>
        <blocks>
            <catalog>
                <rewrite>
                    <product_view_attributes>Inic_Catalog_Block_Product_View_Attributes</product_view_attributes>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

2:view.php
community\Inic\Catalog\Helper\Product\view.php

code of view.php

class Inic_Catalog_Helper_Product_View extends Mage_Catalog_Helper_Product_View
{
    public function gevalnow($param)
    {
      return $param
    }
}

now i have written custom code in my root folder say test.php

<?php
require_once('app/Mage.php'); //Path to Magento
umask(0);
Mage::app();

$helper = Mage::helper('inic_catalog/product_view')->gevalnow('Standard');
print_r($helper);// get value from function in view.php

i get below error:

Fatal error: Class 'Mage_Inic_Catalog_Helper_Product_View' not found in /home/keviainc/public_html/app/Mage.php on line 546

how can i do it pls guide ??..

Best Answer

You have to see what is the tag for the helper in app/code/community/Inic/Catalog/etc/config.xml. Search for <helpers>. Most probably it is:

    <helpers>
        <inic_catalog>
            <class>Inic_Catalog_Helper</class>
        </inic_catalog>
    </helpers>

then you have to use:

Mage::helper('inic_catalog/product_view')->gevalnow();

You have to replace inic_catalog with the string from the config.xml (below <helpers> tag).

Related Topic