magento product attributes and removing them from backend - magento

I want a hidden attribute, or completely not there in backend for some attributes im using to tie to a special product type I created.
I believe I need the attribute assigned to the attribute set in order to be able to use it.. but correct me if I am wrong!
Now that I think about this, I am probably doing this wrong. There is probably a way to add an attribute to PRODUCT_TYPE (my custom product type is "voucher") instead of PRODUCT.
Not sure though.. Hints?

I believe I need the attribute assigned to the attribute set in order to be able to use it
Your attribute needs to be assigned to an attribute set if you want to be able to edit/view the attribute in the Magento Admin area. It sounds like you do not want your attribute visible there, so the simple solution is to: create your attribute without assigning it to an attribute set. You can still assign/edit/view your attribute through database manipulation or by loading the product model and using the magic get & set methods.
$product = Mage::getModel('catalog/product')->load($id);
$product->setFoo('hidden attribute value');
echo $product->getFoo();

Another way is to set the visibility of your attributes by database, have a look here:
Magento - Product Attribute which is not visible/editable in administration
You can also lock attributes and make them readonly for your backend users by using a observer:
Magento read-only and hidden product attributes

Related

How to add attribute default value to pre existing products?

How to add attribute default value to pre existing products?
I created a Global Text area attribute and i added a default value into the text field. The problem that im running into is that the default value that i added is not showing up in the products that i created before i created this attribute.
The text field shows up in the previously created listings, but the default information is not showing up..
YES, this attribute has been added into a attribute set.
I have cleared all the cache
Unique Value No
Values Required yes
Input Validation for Store Owner none
Apply To all products
Use in Quick Search no
Use in Advanced Search no
Comparable on Front-end no
Use In Layered Navigation no
Use In Search Results Layered Navigation no
Use for Promo Rule Conditions no
Position 0
Enable WYSIWYG yes
Visible on Product View Page on Front-end yes
Used in Product Listing no
Used for Sorting in Product Listing no
Any suggestions?
Like i said at the beginning, i have already added the attribute set. Anyways, i found a solution to the problem..
Inside manage products, there is a action called “Update Attributes”. Select all the products that you want to update and then select Update Attributes and add all the new information in.

Remove attributes from a configurable product in Magento

Is there any way to remove an attribute from a configurable product once it’s already been created? I tried to remove an attribute from an attribute set but Magento won’t allow you to if it’s already been assigned to a product. The only way I’ve seen to remove attributes from products is directly in the database (catalog_product_super_attribute table).
You can use this model to get a collection of the catalog_product_super_attribute attribute and proceed to delete the record.
Mage::getResourceModel('catalog/product_type_configurable_attribute_collection')
Be ware, there is an _afterSave method that tries to save the label on another table on Mage_Catalog_Model_Product_Type_Configurable_Attribute, which will cause an exception when deleting.

Magento unable to retrieve attributes on store view

I understand the basic concept of global, website and store scope. We are developing a magento webshop that has 1 website and 2 stores. We have created an attribute called product_status which is in the 'store view' scope.
Issue I'm having is the following:
When I go to a certain product in the magento backoffice , select a certain store from the dropdown menu and set the product_status for this product to let's say "Promotion", I am unable to retrieve this value using the following code on list view (list.phtml):
$_product->getAttributeText('status_type')
Afterward when I do the same, but then for default values, the value IS showing! Afterward when I reset the product_status on default value, this time it WILL work per store.
It's pretty weird that you have to set default values before you can set it per store -_-
Anyone got an idea on a work-around for this issue? Am I doing something wrong?
Figured it out, all you have to do is put the attribute as required and it will force magento to load it on every page that involves products ;)

add attribute in product information -> Inventory tab

Hey, I just realise how easy is to add attributes to the form products in ADMIN, and its working perfectly.
So similarly to setting attributes for General, Prices, Meta Information, Images, Recurring Profiles, Design and More Information, how can I add an attribute to Inventory form?
Thanks in advance for any help.
Unfortunately, the Inventory form is not dynamic like others, and you can't just add an attribute to this form.
If you are good with Magento programming, than you can play with it's block:
app/code/core/Mage/Adminhtml/Block/Catalog/Product/Edit/Tab/Inventory.php
and with it's template:
app/design/adminhtml/default/default/template/catalog/product/tab/inventory.phtml
For me (in Magento v 1.3.2.4) creating attributes the usual way (Catalog>Attributes>Manage Attributes) didn’t work in this case, as the value for that attribute didn’t get saved. In order to be able to save it I had to create this attribute in database table ”cataloginventory_stock_item”.
Only then the value is saved for each product.

Mass Update Magento Field to "Use Default Value"

Is there a way that I can reset a bunch of magento products for a particular store view back to "Use Default Value" It seems once you set the store specific data there is no easy way to unset so that it receives the default data. This is causing me to have to do multiple imports.
I know you want to change "a bunch of products" ...
Just for the usecase someone want to get rid of the store-view-specific values for ALL products:
Just cycle the scope of the attribute from 'Store View' to 'Global' an back to 'Store View' again.
Just remove record from product_entity_[attirubte_type] for the product_id, attribute_id and store_id.
You can use:
core_block_abstract_to_html_before adminhtml event to add the required checkboxes for every attribute in admin mass update form;
then catalog_product_attribute_update_before event to delete the values from the EAV tables for a specific store view, only for those attributes that have the checkbox you injected earlier with core_block_abstract_to_html_before set as checked.
Original answer: https://magento.stackexchange.com/a/45229/16724

Resources