質問

私はテーブルブランドのフィールド 'is_hide_price'を追加しました。 これで、このフィールドの値を製品リストと詳細ページに入手します。

次のコードを試してみました:

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


// Get manufacturer name

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


// Get manufacturer id

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

編集:

モデル:

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

製品リストページ:

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

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

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

出力:

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) {
  }
}
.
役に立ちましたか?

解決

ASと同様に、コードを共有します。

getIsHidePrice()フィールドのデータを取得するためのis_hide_priceを使用します。

任意のフィールドのデータを取得するための

$manufacturer->getData('fieldname')
.

このプロセスでは、 Magic Setter&Getterメソッド

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top