Question

I have added a field 'is_hide_price' in the table brand. Now I want to get this field value on product listing and detail page.

I have tried the following codes:

$_productId = 1782;
$_product = Mage::getModel('catalog/product')->load($_productId);


// Get manufacturer name

$_manufacturerName = $_product->getAttributeText('manufacturer');


// Get manufacturer id

$_manufacturerId = $_product->getManufacturer();

EDITED:

Model:

class Onsis_Brand_Model_Brand extends Mage_Core_Model_Abstract
{
    public function _construct()
    {
        parent::_construct();
        $this->_init('brand/brand');
    }
}

In Product Listing page:

$manufacturer = Mage::getModel('brand/brand')->load($product->getManufacturer());

try {
           Zend_Debug::dump($manufacturer->isHidePrice());exit;

} catch (Exception $ex) {
    echo $ex->getMessage();exit;
}

Output:

Invalid method Onsis_Brand_Model_Brand::isHidePrice(Array ( ) )                                                       



$manufacturer = Mage::getModel('brand/brand')->load($product->getManufacturer());
     Zend_Debug::dump($manufacturer);exit;

object(Onsis_Brand_Model_Brand)#753 (15) {
  ["_eventPrefix":protected] => string(13) "core_abstract"
  ["_eventObject":protected] => string(6) "object"
  ["_resourceName":protected] => string(11) "brand/brand"
  ["_resource":protected] => NULL
  ["_resourceCollectionName":protected] => string(22) "brand/brand_collection"
  ["_cacheTag":protected] => bool(false)
  ["_dataSaveAllowed":protected] => bool(true)
  ["_isObjectNew":protected] => NULL
  ["_data":protected] => array(8) {
    ["brand_id"] => string(2) "41"
    ["title"] => string(15) "Elite Leather A"
    ["filename"] => string(0) ""
    ["content"] => string(46) "Elite Leather Items that are listed indivually"
    ["status"] => string(1) "1"
    ["is_hide_price"] => string(1) "1"
    ["created_time"] => string(19) "2016-04-25 05:17:14"
    ["update_time"] => string(19) "2016-04-25 05:17:14"
  }
  ["_hasDataChanges":protected] => bool(false)
  ["_origData":protected] => array(8) {
    ["brand_id"] => string(2) "41"
    ["title"] => string(15) "Elite Leather A"
    ["filename"] => string(0) ""
    ["content"] => string(46) "Elite Leather Items that are listed indivually"
    ["status"] => string(1) "1"
    ["is_hide_price"] => string(1) "1"
    ["created_time"] => string(19) "2016-04-25 05:17:14"
    ["update_time"] => string(19) "2016-04-25 05:17:14"
  }
  ["_idFieldName":protected] => NULL
  ["_isDeleted":protected] => bool(false)
  ["_oldFieldsMap":protected] => array(0) {
  }
  ["_syncFieldsMap":protected] => array(0) {
  }
}
Was it helpful?

Solution

As per as,you share code :

use getIsHidePrice() for getting data of is_hide_price field.

For getting data of any field try below format

$manufacturer->getData('fieldname')

In this process or use magic setter & getter method

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top