2014-12-10 5 views
5

में उत्पाद विशेषता मान कैसे प्राप्त करें मुझे एक बहुत ही अजीब समस्या है, मैं स्थानीय में उत्पाद विशेषता मान प्राप्त कर सकता हूं लेकिन जब मैं लाइव सर्वर पर जाता हूं, तो मुझे खाली मान मिलता है। Magento संस्करण 1.6.2। दोनों को स्थानीय और जीने सर्वर परMagento

$product = Mage::getModel('catalog/product')->load($_item->getProductId()); 
$my_attribute = $product->getAttributeText('my_attribute'); 

पीएचपी 5.3 और Apache 2.2

+0

ऐसा और भी बहुत हम अपने prod सर्वर के बारे में बता सकते हैं नहीं है ... –

+0

यह एक डेबियन है। स्थानीय विंडोज 7 wampserver – Ali

+0

अगर कोई जानता है कि यह सर्वर पर काम करने का कारण बन सकता है और किसी दूसरे पर नहीं। जब मैं var_dump ($ product) करता हूं तो मुझे लाइव सर्वर पर my_attribute नहीं मिलता है लेकिन मुझे इसे स्थानीय – Ali

उत्तर

28

इन बातों का प्रयास करें::

विशेषता मान प्राप्त करने के लिए, मैं इस कोड का उपयोग

$attribute_option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, 'my_attribute', $storeId); 
$product = Mage::getModel('catalog/product') 
    ->setStoreId($storeId) 
    ->setData('my_attribute', $attribute_option_id); 

$text = $product->getAttributeText('my_attribute'); 

या

$_id = $this->getProduct()->getId(); 
$_resource = Mage::getSingleton('catalog/product')->getResource(); 
$optionValue = $_resource->getAttributeRawValue($_id, [ATTRIBUTE_ID/ATTRIBUTE_CODE], Mage::app()->getStore()); 
echo $optionValue; 

या

$attribute_value = $product->getResource()->getAttribute($attribute_code)->getFrontend()->getValue($product); 

चियर्स :-)

+1

पर मिलता है धन्यवाद @ girish-sh, मैंने इन सभी को आजमाया है। ($ विकल्प के रूप में $ this-> getItemOptions()) \t foreach: लेकिन क्या काम करने के लिए लग रहा था 'अगर ($ this-> getItemOptions()) है \t \t अगर ($ विकल्प [ 'लेबल'] == ' मेरी विशेषता '): \t \t \t $ taille = nl2br ($ विकल्प [' value ']); \t \t endif; \t endforeach; endif; 'और यह मेरे लिए स्थानीय – Ali

+0

पर काम नहीं करता है क्या आपको इस कोड को चलाने के बाद कोई त्रुटि मिल रही है? –

+0

कोई त्रुटि नहीं, और मुझे लाइव सर्वर पर सही मान मिलता है, लेकिन स्थानीय पर मुझे खाली मान मिलता है। – Ali