2012-07-30 12 views
11

मैं Magento के साथ एक नौसिखिया हूँ। मैं एक श्रेणी में दो कस्टम छवि फ़ील्ड जोड़ना चाहता हूं। मैं अपने मॉड्यूल के लिए स्थापना फ़ाइल के साथ एक मॉड्यूल बनाया है:Magento में किसी श्रेणी में कस्टम छवि फ़ील्ड कैसे जोड़ें?

$installer = $this; 
$installer->startSetup(); 

$setup = new Mage_Eav_Model_Entity_Setup('core_setup'); 
$entityTypeId  = $setup->getEntityTypeId('catalog_category'); 
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId); 
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId); 

$setup->addAttribute('catalog_category', 'image1', array(
    'input'   => 'image', 
    'type'   => 'file', 
    'group' => 'General', 
    'label'   => 'Additional image 1', 
    'visible'  => 1, 
    'required'  => 0, 
    'user_defined' => 1, 
    'frontend_input' =>'', 
    'global'  => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 
    'visible_on_front' => 1, 
)); 

$setup->addAttributeToGroup(
$entityTypeId, 
$attributeSetId, 
$attributeGroupId, 
'image1', 
'999' //sort_order 
); 

$installer->endSetup(); 

मैं छवि क्षेत्र देख सकते हैं जब संपादन या नई श्रेणी लेकिन डेटाबेस के लिए अपनी बचत नहीं जोड़ रहा है। इसे कार्यशील कैसे करें? उन लोगों के बजाय

'type' => 'varchar', 
'input' => 'image', 
'backend' => 'catalog/category_attribute_backend_image', 

: धन्यवाद

उत्तर

29

श्रेणियों के लिए एक नई छवि विशेषता को जोड़ने के लिए, आप अपने सेटअप में उन मूल्यों को उपयोग करने की आवश्यकता

'input' => 'image', 
'type' => 'file', 
+2

बहुत बहुत शुक्रिया! – Joonas

+1

साल पुराना ... और अभी भी लोगों की मदद करना! धन्यवाद! – eklingen

संबंधित मुद्दे