كيفية الحصول على الصانع سمات أخرى غير معرف اسم المنتج lisitng و التفاصيل الصفحة ؟
-
29-09-2020 - |
سؤال
لقد تم إضافة حقل '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')
في هذه العملية أو استخدام السحر اضع & طريقة حاصل
لا تنتمي إلى magento.stackexchange