Magento : Add custom image attribute to category
Just copy paste the below code in header.phtml and run yourmagento once, your attribute will be created and you can see in backend under manage category. After you are done remove this code again.
------------------------------------------------------------------------------------------
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('catalog_category', 'sliderimage', array(
'group' => 'General',
'input' => 'image',
'type' => 'varchar',
'label' => 'Slider Image',
'backend' => 'catalog/category_attribute_backend_image',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
------------------------------------------------------------------------------------------
Just copy paste the below code in header.phtml and run yourmagento once, your attribute will be created and you can see in backend under manage category. After you are done remove this code again.
------------------------------------------------------------------------------------------
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('catalog_category', 'sliderimage', array(
'group' => 'General',
'input' => 'image',
'type' => 'varchar',
'label' => 'Slider Image',
'backend' => 'catalog/category_attribute_backend_image',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
------------------------------------------------------------------------------------------
Thanks afroz, it really helped me
ReplyDeleteGreat work!!!
ReplyDeleteHi Great work there,
ReplyDeleteWell how can we display this newly added attribute on the backend?
The created attribute is automatically visible in backend
Deletewell it rly helped nd it work but how can i verify validation ? when i put required as 1 even on upload it say my atttribute is empty
ReplyDelete@kareem .. i cannot get your point . can you please mail me the issue with screenshot.
DeleteThank you so much for this. after a complete waste of day this saved my ass!
ReplyDeletein which file i use the above code.
ReplyDeleteaddAttribute('catalog_category', 'sliderimage', array(
'group' => 'General',
'input' => 'image',
'type' => 'varchar',
'label' => 'Slider Image',
'backend' => 'catalog/category_attribute_backend_image',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
?>
its not working for me
Guys, this is ridiculous. You don't even know what an sql update is.
ReplyDeleteThe code is correct, but putting it into header and then removing - nothing to say.
True that man
Deleteworking great
ReplyDeleteHow to display this category image on the frontend?
ReplyDeleteI dont know it neither. I've tried everything..
DeletegetStoreCategories();
Deleteforeach ($storeCategories as $_category):
$_categoryModel = Mage::getModel('catalog/category')->load($_category->getId());
$op = $_categoryModel->getData('sliderimage');
echo Mage::getBaseUrl('media').'catalog/category/'.$op;
endforeach;
?>
How to create more than 1 image fields.
ReplyDeleteHow can I call it? getSliderimage();?> doesn't work.
ReplyDeletegetStoreCategories();
Deleteforeach ($storeCategories as $_category):
$_categoryModel = Mage::getModel('catalog/category')->load($_category->getId());
$op = $_categoryModel->getData('sliderimage');
echo Mage::getBaseUrl('media').'catalog/category/'.$op;
endforeach;
?>
I found this post searching for the way to show the category image on the frontend, looking at the last comments I think I'm probably not the only one. The answer is: reindex. Then the image filename will be available with ->getData('sliderimage') on the frontend.
ReplyDelete$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
ReplyDelete$setup->addAttribute('catalog_category', 'sliderimage', array(
'group' => 'General',
'input' => 'image',
'type' => 'varchar',
'label' => 'Slider Image',
'backend' => 'catalog/category_attribute_backend_image',
'visible' => 1,
'required' => 0,
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
));
Hey Thanks for providing code
Its working in localhost but in server not displaying this field.
when i trying to get the attr value using getData it return the file name only, how can i retrieve the full image url or generate it ?
ReplyDeleteYou can concatenate the media_url and filename to get the end result.
DeleteThanks for this code. Its really amazing working..
ReplyDeleteThanks for your comments. Follow my blog to get notifications as soon as add new posts.
DeleteGreat Read! I am impressed on how you make your article easy to understand. I'll come back for more :D
ReplyDeleteJaps Buidon is a Social Media Specialist and belongs to a team of Magento Developer in Florida. He loves hiking as well as electronics.
Thanks your help, it's useful
ReplyDeletenice thanks for sharing
ReplyDeletehi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here.
ReplyDeleteKindly keep blogging. If anyone wants to become a Front end developer learn from javascript and jquery training in chennai .
or learn thru Javascript Training in Chennai.
Nowadays JavaScript has tons of job opportunities on various vertical industry. javascript and jquery training in chennai
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteSelenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
I am definitely enjoying your website. You definitely have some great insight and great stories.
ReplyDeletepython Training in Pune
python Training in Chennai
python Training in Bangalore
mmorpg oyunlar
ReplyDeleteınstagram takipçi satin al
Tiktok Jeton Hilesi
TİKTOK JETON HİLESİ
Saç ekim antalya
referans kimliği nedir
instagram takipçi satın al
mt2 pvp
TAKİPÇİ
fon perde modelleri
ReplyDeletesms onay
TÜRK TELEKOM MOBİL ÖDEME BOZDURMA
nft nasıl alınır
Ankara evden eve nakliyat
trafik sigortası
Dedektör
web sitesi kurma
aşk kitapları
Good content. You write beautiful things.
ReplyDeletemrbahis
hacklink
korsan taksi
vbet
vbet
sportsbet
taksi
hacklink
mrbahis
Good text Write good content success. Thank you
ReplyDeleteslot siteleri
bonus veren siteler
poker siteleri
betpark
tipobet
kralbet
betmatik
kibris bahis siteleri
kocaeli
ReplyDeletekonya
kuşadası
kütahya
malatya
MP5QJT
manisa
ReplyDeletemaraş
mardin
marmaris
mersin
QNZNSU
beşiktaş
ReplyDeleteeyüpsultan
gebze
kaş
tekirdağ
İ06X6
kağıthane
ReplyDeletemuğla
tuzla
etiler
maltepe
WXD3
kütahya
ReplyDeletesivas
urfa
ağrı
ısparta
QHA8JZ