제품 목록 및 상세 페이지에서 ID 및 이름 이외의 제조업체 속성을 얻는 방법은 무엇입니까?

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

문제

테이블에 '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) {
  }
}
도움이 되었습니까?

해결책

그에 따라 코드를 공유합니다.

사용 getIsHidePrice() 데이터를 얻기 위해 is_hide_price 필드.

모든 필드의 데이터를 얻으려면 아래 형식을 시도하십시오.

$manufacturer->getData('fieldname')

이 과정에서 또는 사용 매직 세터 및 게터 방법

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top