I need to create New Label Icon for selected categories, How can I create new labels icons like,
-
create a category custom attribute, If category set that attribute in backend then label will show. – Ram Pratap Singh Gour Dec 28 '16 at 05:23
-
could you pls explain briefly – Gem Dec 28 '16 at 05:43
-
1Below answer is right you have to go through with that. – Ram Pratap Singh Gour Dec 28 '16 at 05:55
-
@Ramsipl : could you pls join chat – Gem Dec 28 '16 at 08:00
-
http://chat.stackexchange.com/rooms/50817/new-category-label – Gem Dec 28 '16 at 08:00
-
Not working.... – Gem Jan 02 '17 at 11:58
-
are you using infortis ultimo theme ?? – Murtuza Zabuawala Jan 02 '17 at 12:09
-
Nope, am using https://www.templatemonster.com/fitness-magento-free-theme.html#gref – Gem Jan 02 '17 at 12:12
-
@JeevaRathinam you just need to create one yes/no attribute for category in backend and add condition of that attribute before displaying that category name at frontend. – Nits Jan 04 '17 at 05:41
-
@Nits : How can i create yes/no attribute for category in backend – Gem Jan 04 '17 at 06:05
-
@JeevaRathinam check below URL https://gist.github.com/aleron75/7304592 http://magento.stackexchange.com/questions/4185/add-a-extra-category-attribute-under-general-infomation-tab http://magento.stackexchange.com/questions/11406/add-category-custom-attribute-with-dropdown – Nits Jan 05 '17 at 10:27
1 Answers
Create a custom category attribute (Yes or no), You can get help here :
https://www.atwix.com/magento/add-category-attribute/
http://inchoo.net/magento/how-to-add-new-custom-category-attribute-in-magento/
https://magento.stackexchange.com/a/11408/21339
Set the value of those category (yes/no) from backed and then within your template put you logic.
Edit
Here is the code for this, I have not tested this code, Please do it on demo site.
Step 1 : Add the following code in your app/etc/Arunendra_Pratap.xml file.
<?xml version="1.0"?>
<config>
<modules>
<Arunendra_Pratap>
<active>true</active>
<codePool>local</codePool>
</Arunendra_Pratap>
</modules>
</config>
Step 2 :Add the following code to the app/code/local/Arunendra/Pratap/etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Arunendra_Pratap>
<version>0.0.1</version>
</Arunendra_Pratap>
</modules>
<global>
<resources>
<add_category_attribute>
<setup>
<module>Arunendra_Pratap</module>
<class>Mage_Catalog_Model_Resource_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</add_category_attribute>
<add_category_attribute_write>
<connection>
<use>core_write</use>
</connection>
</add_category_attribute_write>
<add_category_attribute_read>
<connection>
<use>core_read</use>
</connection>
</add_category_attribute_read>
</resources>
</global>
</config>
Step 3 :Add the custom attribute to the app/code/local/Arunendra/Pratap/sql/add_category_attribute/mysql4-install-0.0.1.php file as shown below.
<?php
$this->startSetup();
$this->addAttribute(Mage_Catalog_Model_Category::ENTITY, 'is_new_cat', array(
'group' => 'General Information',
'input' => 'select',
'type' => 'text',
'label' => 'Is new',
'backend' => '',
'visible' => true,
'required' => false,
'visible_on_front' => true,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'source' => 'eav/entity_attribute_source_boolean',
));
$this->endSetup();
Edit :
You need to modify this file /app/code/community/WP/CustomMenu/Block and
find this public function drawCustomMenuItem and replace with this
public function drawCustomMenuItem($category, $level = 0, $last = false)
{
if (!$category->getIsActive()) return;
$htmlTop = array();
$id = $category->getId();
$isNew = $category->getIsNewCat()== 1 ? 'new-cat-class' : '';
// --- Static Block ---
$blockId = sprintf(self::CUSTOM_BLOCK_TEMPLATE, $id); // --- static block key
#Mage::log($blockId);
$collection = Mage::getModel('cms/block')->getCollection()
->addFieldToFilter('identifier', array(array('like' => $blockId . '_w%'), array('eq' => $blockId)))
->addFieldToFilter('is_active', 1);
$blockId = $collection->getFirstItem()->getIdentifier();
#Mage::log($blockId);
$blockHtml = Mage::app()->getLayout()->createBlock('cms/block')->setBlockId($blockId)->toHtml();
// --- Sub Categories ---
$activeChildren = $this->_getActiveChildren($category, $level);
// --- class for active category ---
$active = ''; if ($this->isCategoryActive($category)) $active = ' act';
// --- Popup functions for show ---
$drawPopup = ($blockHtml || count($activeChildren));
if ($drawPopup) {
$htmlTop[] = '<div id="menu' . $id . '" class="menu' . $active . '" onmouseover="wpShowMenuPopup(this, event, \'popup' . $id . '\');" onmouseout="wpHideMenuPopup(this, event, \'popup' . $id . '\', \'menu' . $id . '\')">';
} else {
$htmlTop[] = '<div id="menu' . $id . '" class="menu' . $active . '">';
}
// --- Top Menu Item ---
$htmlTop[] = '<div class="parentMenu">';
if ($level == 0 && $drawPopup) {
$htmlTop[] = '<a class="level' . $level . $active .$isNew. '" href="javascript:void(0);" rel="'.$this->getCategoryUrl($category).'">';
} else {
$htmlTop[] = '<a class="level' . $level . $active . .$isNew.'" href="'.$this->getCategoryUrl($category).'">';
}
$name = $this->escapeHtml($category->getName());
if (Mage::getStoreConfig('custom_menu/general/non_breaking_space')) {
$name = str_replace(' ', ' ', $name);
}
$htmlTop[] = '<span>' . $name . '</span>';
$htmlTop[] = '</a>';
$htmlTop[] = '</div>';
$htmlTop[] = '</div>';
$this->_topMenu[] = implode("\n", $htmlTop);
// --- Add Popup block (hidden) ---
if ($drawPopup) {
$htmlPopup = array();
// --- Popup function for hide ---
$htmlPopup[] = '<div id="popup' . $id . '" class="wp-custom-menu-popup" onmouseout="wpHideMenuPopup(this, event, \'popup' . $id . '\', \'menu' . $id . '\')" onmouseover="wpPopupOver(this, event, \'popup' . $id . '\', \'menu' . $id . '\')">';
// --- draw Sub Categories ---
if (count($activeChildren)) {
$columns = (int)Mage::getStoreConfig('custom_menu/columns/count');
$htmlPopup[] = '<div class="block1">';
$htmlPopup[] = $this->drawColumns($activeChildren, $columns);
$htmlPopup[] = '<div class="clearBoth"></div>';
$htmlPopup[] = '</div>';
}
// --- draw Custom User Block ---
if ($blockHtml) {
$htmlPopup[] = '<div id="' . $blockId . '" class="block2">';
$htmlPopup[] = $blockHtml;
$htmlPopup[] = '</div>';
}
$htmlPopup[] = '</div>';
$this->_popupMenu[] = implode("\n", $htmlPopup);
}
}
and add this style
.new-cat-class{ color:red !important;}
Note: if this work revert back the changes and override this block with local module. http://inchoo.net/magento/overriding-magento-blocks-models-helpers-and-controllers/
Hope this will help you.
-
-
-
@JeevaRathinam just read above the pink line "script must be located in the folder with the same name (in our case path will be ‘app/code/community/Atwix/CustomCategoryAttribute/sql/add_category_attribute’) " – Arunendra Dec 28 '16 at 06:46
-
-
-
-
-
-
-
-
-
-
I have checked same code in my local magento 1.9.2.4 and it's working fine.Please flush your magento cache – Arunendra Dec 28 '16 at 10:01
-
-
@ arunendra : could you share screenshots, may I see the new label on category – Gem Dec 28 '16 at 10:34
-
@ Arunendra: After completion of what you told, Finally I get (is new) on the backend, after click new, there are no changes on the front end, help me. – Gem Dec 28 '16 at 12:22
-
-
-
Am using the extension, https://www.magentocommerce.com/magento-connect/responsive-custom-menu.html – Gem Jan 02 '17 at 12:53
-
