Domanda

Ho aggiunto un campo 'is_hide_price' nella tabella Brand . Ora voglio ottenere questo valore di campo sulla lista dei prodotti e sulla pagina dei dettagli.

Ho provato i seguenti codici:

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


// Get manufacturer name

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


// Get manufacturer id

$_manufacturerId = $_product->getManufacturer();
.

Modificato:

Modello:

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

Nell'elenco dei prodotti Pagina:

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

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

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

Uscita:

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) {
  }
}
.
È stato utile?

Soluzione

Come a come, si condividi il codice:

Utilizzare getIsHidePrice() per ottenere dati del campo is_hide_price.

Per ottenere dati di qualsiasi campo prova sotto formato

$manufacturer->getData('fieldname')
.

In questo processo o utilizzare Magic Setter & Gettter Method

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange
scroll top