There is a specific set of fields that are displayed by default on the product settings page. However, there can be certain conditions when the fields should not be displayed, for instance: Minimum Sell Price attribute should be editable for the Admin access level users, but others should have no access to this field.
Add a new event to config.xml core_block_abstract_prepare_layout_befor
Partner With Us
Let's discuss how to grow your business. Get a Free Quote.
Talk to Igor
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<adminhtml> <events> <core_block_abstract_prepare_layout_before> <observers> <belvg_minsellprice_hide_attribute> <type>singleton</type> <class>belvg_minsellprice/observer</class> <method>removeAttribute</method> </belvg_minsellprice_hide_attribute> </observers> </core_block_abstract_prepare_layout_before> </events> </adminhtml> |
Then add the following code to Observer.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public function removeAttribute(Varien_Event_Observer $event) { $block = $event->getBlock(); if (!($block instanceof Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs)) { return; } // add your conditional check here $editableAttributes = $block->getProduct()->getTypeInstance()->getEditableAttributes() unset($editableAttributes['min_sell_price']); // Remove fields which you need hide $block->getProduct()->setData('_cache_editable_attributes', $editableAttributes); } |
As a result the field Minimum Sell Price will not be displayed on the product settings page.
Partner With Us
Looking for a partner to grow your business? We are the right company to bring your webstore to success.
Talk to Igor
Hi Johann,
You can add a new condition $block->getProduct()->getTypeId() == ‘configurable’ and then hide an attribute.
Hi! I need help hiding an attribute from configurable product in admin, but I want it to be visible in simple products.
Also, I don’t know to which files you are referring to in the tutorial. Sorry! I’m a Magento newbie.
Thank you!
Prajakta,
Thank you for this question!
We will do our best to answer it in our future articles.
How to achieve same in magento 2 ? I have tried, but not getting the exact event in which we can capture the attributes and unset them.