3

Fatal error: Class 'Mage_Inspiresettings_Helper_Data' not found in /home/inpxcare/public_html/brandz/app/Mage.php on line 547

Currently my Data.php contains

<?php

class Magik_Inspiresettings_Helper_Data extends Mage_Core_Helper_Abstract {}
{

    protected function _loadProduct(Mage_Catalog_Model_Product $product)
    {
        $product->load($product->getId());
    }

        public function getLabel(Mage_Catalog_Model_Product $product)
    {
        $html = '';
        if (!Mage::getStoreConfig("inspiresettings/inspiresettings_labels/new_label") &&
            !Mage::getStoreConfig("inspiresettings/inspiresettings_labels/sale_label") ) {
            return $html;
        }

        $this->_loadProduct($product);

        if ( Mage::getStoreConfig("inspiresettings/inspiresettings_labels/new_label") && $this->_isNew($product) ) {
                        $html .= '<div class="new-label new-'.Mage::getStoreConfig('inspiresettings/inspiresettings_labels/new_label_position').'"> '.Mage::getStoreConfig('inspiresettings/inspiresettings_labels/new_label_text').' </div>';
                }
                if ( Mage::getStoreConfig("inspiresettings/inspiresettings_labels/sale_label") && $this->_isOnSale($product) ) {
                        $html .= '<div class="sale-label sale-'.Mage::getStoreConfig('inspiresettings/inspiresettings_labels/sale_label_position').'"> '.Mage::getStoreConfig('inspiresettings/inspiresettings_labels/sale_label_text').' </div>';
                }

        return $html;
    }  

        protected function _checkDate($from, $to)
    {
        $date = new Zend_Date();
        $today = strtotime($date->__toString());

        if ($from && $today < $from) {
            return false;
        }
        if ($to && $today > $to) {
            return false;
        }
        if (!$to && !$from) {
            return false;
        }
        return true;
    }  

        protected function _isNew($product)
    {
        $from = strtotime($product->getData('news_from_date'));
        $to = strtotime($product->getData('news_to_date'));

        return $this->_checkDate($from, $to);
    }  

        protected function _isOnSale($product)
    {
        $from = strtotime($product->getData('special_from_date'));
        $to = strtotime($product->getData('special_to_date'));

        return $this->_checkDate($from, $to);
    }  
}

Added the class in /app/code/local/magik/Inspiresettings/etc/config.xml without space and case-sensitive

<global>
      <helpers>
        <Inspiresettings>
          <class>Magik_Inspiresettings_Helper</class>
        </Inspiresettings>
      </helpers>
    </global>

Code in app/Mage.php on line 547 is

/**
     * Retrieve helper object
     *
     * @param string $name the helper name
     * @return Mage_Core_Helper_Abstract
     */
    public static function helper($name)
    {
        $registryKey = '_helper/' . $name;
        if (!self::registry($registryKey)) {
            $helperClass = self::getConfig()->getHelperClassName($name);
            self::register($registryKey, new $helperClass);
        }
        return self::registry($registryKey);
    }
  • are you calling your helper from anywhere? – rob3000 Oct 9 '15 at 4:10
  • your class should extend Mage_Core_Helper_Data instead of Mage_Core_Helper_Abstract to add more layer – Minesh Patel Oct 9 '15 at 4:25
3

The answer above is why you get that error- Magento can't find your helper because of the capital letter in your XML.

On a side note though, you have a syntax error on the first line of your helper - closed brace by accident I assume. You also have no public methods in your helper, which may be deliberate for extending with usable classes but I imagine it's a mistake - none of your helper methods will be usable if they stay as protected methods.

If you have magerun installed you can test your models, helper etc declarations via the command line to ensure they are configured properly:

n98-magerun.phar dev:class:lookup helper inspiresettings/data

If it resolves to your class name it is correct. If it resolves to Mage_... it's not. If you don't have magerun you should install it.

2

You have to correct this line:

class Magik_Inspiresettings_Helper_Data extends Mage_Core_Helper_Abstract //{} unnecessary 
{
...........
...........
}

Also change this in config.xml

<global>
  <helpers>
    <inspiresettings>
      <class>Magik_Inspiresettings_Helper</class>
    </inspiresettings>
  </helpers>
</global>

You should also change folder name of magik to Magik in app/code/local

1

You have wrongly defined the helper class group name in config.xml .

You have defined it as Inspiresettings (<Inspiresettings>)but it should be in lower case letters eg. inspiresettings as per as Magento standards (suggestion not requirement).

<global>
  <helpers>
    <inspiresettings> <!-- this call module helper class group name -->
      <class>Magik_Inspiresettings_Helper</class>
    </inspiresettings>
  </helpers>
</global>

Also @Adarsh mentioned, the folder name should be Magik.

Also global config file name should be changed accordingly.

Magik_Inspiresettings.xml should live at app/etc/modules

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.