¿Cómo obtener atributos del fabricante que no sean ID y nombre en la página de detalles y la página de detalles?

magento.stackexchange https://magento.stackexchange.com/questions/112404

Pregunta

He agregado un campo 'is_hide_price' en la tabla marca . Ahora quiero obtener este valor de campo en el listado de productos y la página de detalles.

He probado los siguientes códigos:

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


// Get manufacturer name

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


// Get manufacturer id

$_manufacturerId = $_product->getManufacturer();

editado:

Modelo:

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

En el listado del producto Página:

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

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

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

Salida:

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) {
  }
}
¿Fue útil?

Solución

Según lo que como, comparte código:

Use getIsHidePrice() para obtener datos del campo de is_hide_price.

Para obtener datos de cualquier campo intente a continuación el formato

$manufacturer->getData('fieldname')

En este proceso o use Método Magic Setter & Getter

Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange
scroll top