set super product attributes 'Attribute Name' to 'use default ' - magento

How can i change programmatically for all configurable products 'Attribute Name' use default ? I need to checked options. The place where I want to checked is marked in red
http://i.imgur.com/LFxR8mj.png

I know this is a old post, but as it is still seems to be unsolved I thought I would add this for the next person that comes looking.
The table you need to update is catalog_product_super_attribute_label you will see a value for all products. If you update this table to 'use_default' as 1 this will check the box and use the default attribute label.
I hope this helps somebody.

It seems like what you're trying to do is remove an attribute value for certain products at a certain store scope (in which case it will fall back to 'use default' mode and acquire the next attribute value available , whether that be defined at the website level or global level). You need to remove the value entries from the entity value table (e.g. catalog_product_entity_varchar) where the attribute ID and store ID match the ones you're trying to remove. You could do it with raw SQL fairly easily:
DELETE from your_entity_valuetype WHERE attribute_id=X and store_id=Y;
Plug in your attribute ID (you can grab that from the eav_attribute table) and store ID, and the table for the attribute value.

Related

Servicenow - Service Catalog Reference Field - Insert different column than the display value

Let me describe my problem:
I have a table for all my IT-Services. I reference to this table more than once, for different purposes. Most of the time I need to reference to the name of the service. That's why I keep the name as displayed value.
One Column of that table is a service_id (custom field) which is for example "Service_004". Now in a catalog request Item the User has to fill in the service_id in a reference field.
But since I have the name as displayed value, and I need it in other forms, I am unable to reference to the service_id.
Using the variable attributes field I managed to let the service be found using the autocomplete function. But in the reference field I still get the servicename. I know that I can change the display value in the dictionary, but this breaks other functions. So what I need is to change the display value just for one reference field.
Also I tried to create a new table called IT-Services2 with reference to my table IT-Services. Then I switched the display to true in the new table for my service_id, but this will even change it in the parent table.
Perhaps an onChange client script utilizing g_form.setLabelOf() ?
http://wiki.servicenow.com/index.php?title=GlideForm_(g_form)#setLabelOf
Maybe I'm not fully understanding your question...
I ran into this issue before, what you can do is create select box variable and use an on load client script to populate the list with the service_id(s) from the table you are referencing.
I would write a script include to pull the data from the table and call it from the client script via GlideAjax.

How to get values from catalog_product_entity_varchar?

I'm trying since hours to get some values from the table
catalog_product_entity_varchar
with no succes.
How is this table connected to the products?
I have a product with a custom attribute "materials" and I found the values in this mentioned table.
There is no result when I try to do this:
$_product->getAttributeText('materials');
#credit goes to this answer: https://magento.stackexchange.com/questions/13330/how-to-get-dropdown-and-multiple-select-value-for-a-product-collection
the following should work:
$_product->getAttributeText('some_dropdown_attr');
Therefore only the following could be happening:
You must have mis-named your dropdown attribute
Ensure that the attribute has valid values applied on the current store view
If all else fails, there may be a problem with your attribute setup code; for instance, not visible in the frontend isn't set properly and you're using flat tables...
In that case to debug output it with the following code:
$attr = $_product->getResource()->getAttribute('some_dropdown_attr')->getFrontend()->getValue($_product);
If that works check your catalog attribute configuration or disable flat indexes.
Hope this help !!

How to assign attribute to the product without attribute set in magento

I want to assign the attribute value to the product page in the catalog->manage products without assigning into attribute set in magento.
Is it possible to do like this in magento 1.8? If yes,how to do?
Thanks in advance
You question is not really clear, but I hope I understood correctly.
You cannot assign attributes directly to the product.
There is direct relation between a product and an attribute entities.
A product can have a certain attribute value. That's it.
Even if you insert the value for that attribute manually in the correct table it will be useless.
That value will be a zombie value. It will be ignored by the application and it will only take up space in your db.
The design of the app is like this.
An attribute set contains attributes (in a many to many relation).
A product has an attribute set as a parent entity (so one to many relation).
A product can have values for the attributes in the attribute set it is assigned to.

Magento: In Magento Flat tables why do some attributes have value stored while others do not?

I was looking at the Flat Tables and saw this perculiar behaviour. For some of my attributes like 'language' there were two columns (language and language class) while for other 'age' there were no such values stored.
I could not find any settings in the attribute field which described this and it seems to follow no pattern.
Also in the place where language is stored language is int(11) and langauge_value is varchar(256) while in age it is varchar(256) but actually stores just a number.
UPDATE:
I think the question was not understood. I am seeing some attributes being shown as varchar(255) while some attributes being shown as attributes (int(11)) and attribute_value (varchar(255)
Found the answer:
For simple dropdown, the attribute_value is also added to the flat table.values being shown.
For Multiselect, the values are not added to the Flat table.
Pattern is very simple, when you create new attribute, you select whether it is used for search/layered navigation. If yes - indexer will add new column for this attribute to flat table.
Answered under the topic Can I add other attributes to magento's flat product catalog table? And don't get too slap-happy in adding attributes to your Flat Product Catalog table. It has a row limit defined by MySQL limitations.
I believe it is all about the scope of the variable and if it is available on the frontend of the website (where the flat table is used).
If you set an attribute to be displayed on the front end of the website (or I believe if its scope is set to store view, but dont quote me on that) it will be put into the flat table.
One way I generally look at it is, if when I create the attribute I need to reindex the flat product index, it is going to go in there.

configurable product Issue

I am facing a problem while making product configurable i used this link http://www.magentocommerce.com/knowledge-base/entry/tutorial-creating-a-configurable-product/ but In associated tab the products doesnt show up
Thankds and regards
2 things you can check:
Are you sure that the simple products you want to associate to the configurable product actually have values for the attribute you made the configurable product configurable by? So if you made a configurable product based on 'color', do the simple products have values selected for 'color'?
When you are looking at the associated products tab, and seeing the blank grid there, have you tried resetting the filter, or selecting 'No' or 'Any' in the first column? If it is set to 'Yes', it is only looking for products that have already been associated.
How does configurables products linking works in magento ?
Getting rid of being trolled by the linking of configurables products with their simple counterparts ? Let's explain how does Magento link'em... and why it sometimes doesn't work as expected.
The first point to understand is how the data persistence is managed by the application. As expected, links are stored in database. Thought it was in catalog_product_relation ? You were wrong. It should be too simple to respect the Magento's spirit :)
catalog_product_relation vs catalog_product_super_* tables
I won't tell catalog_product_relation is useless – in fact, it's necessarily there for something. But from version 1.5+, this is not there that links are stored, and I can't explain what does its purpose is.
First step
The first step of the linking process is the definition of the configurable product's configurable attributes. Supposing we're creating a new configurable product from an attribute set having a few global-select attributes.
If you try to access to your configurable product, the application will ask you which of 'em should be used as configurable attributes, in a form using a list of checkboxes associated to each attribute. By selecting some and saving your product, you insert in catalog_product_super_attribute a row by attribute (an association between product's id and attribute's one).
Second step
The second step is the linking itself with the associated simple products. This step is a bit more complex, because it implies some checks of the database's content, which we'll detail further below. Some rules to keep in mind about that :
only products having the same attribute set as the current configurable product
options must be defined for the configurable attribute
only one simple can be linked for a given configurable attribute combination
simple can be linked to as many configurables as desired
Then, what happens when we go to our configurable's associated products tab ? Don't be scray to not see any of your simple-corresponding-product in the list that display – it's filter is configured by default to display only already linked products. Here is what happens behind the scene :
the application go check the catalog_product_super_attribute table, and bring back each corresponding attribute id defined there for the current product (our configurables attributes)
from them, it will go check eav_attribute to get some details about them – in which ones the backend_type, which is the more important part of this explanation
parallely, the catalog_product_super_link table is checked too. Any product linked to current_product is a potential linked product
for each attribute, the application check if a value exists in catalog_product_entity_{backend_type} for each potentially linked product. Note that if no value exists for a given product, it won't be validated nor as a potential link nor than an effective one, even if it has already been linked (we'll see below what it implies for attribute creation).
To resume, only products with a valid value are diplayable and effectively linked / linkable. Note that all of the combination must have valid values – if any of the configurable's attribute as none, game over, you'll not have any link between your simple product and its configurable counterpart.
We should think it's ok, and everything will go right now, since we know how everything works in database. That's true if you always create your attributes from the application's back-office. But since scripting attributes is a very common way to proceed, you're much like to be in this second case, which implies a potential HUGE problem.
Programatically created attributes and... What the hell !?! This attribute has change of backend type !
Edit note: this case happens effectively when using a eav/entity_attribute_source_table source model
This a trouble I personnally runned through. If you check attributes backend models in database (only for select attributes – we do not care about which ones are not usable as configurable's ones), you'll see some varchar, some int... In short, multiple ones, and we could rightfully expect any of them works.
And they do so. Since you do not decide to add an option to your attribute from the back-office, or anything else that require to click on the « save » button on the attribute page.
The point is that when you save your attribute, Magento, in it's great goodness, ask itself what is the type of the attribute you ask him to save. The point is that before anything else, it's a select. And a select has options. And options has id. Which are the values that will be put in catalog_product_entity_{backend_type}, in any case. The label is just properly ignored in that (it's stored in it's proper table and doesn't affect anything there). Only the id is used.
And what shall we expect from Magento :) ?
It just change the attribute backend type to int systematically.
So, if you have products that used to be linked and are no more, go check the catalog_product_entity_{backend_type} tables and the eav_attribute one – compare the backend type, look for values in each values table... If you find 'em in a table that does not correspond, you get your problem. You have a few ways to correct the problem, here are the both I find myself (and I really do not promote the first, which I put only for explanation purpose).
First way: get the backend type back (The Dirty Trick)
It has changed to int ? Don't care. Bring it back to what you want it to be.
Why it's dirty : because you want you user to be able to update it's attributes when he wants. If you update the backend type to varchar, for example, any label change in the back-office for an option will rollback to int as it will be saved.
Second way: let's correct everything ! (The Right Thing)
You can pass throught this... bad situation, with a bit of MySQL without harming your database. But please, first, dump it. Then you'll require 4 steps :
check that you don't already have the data in catalog_product_entity_int table
duplicate the rows of the current ...entity{attribute} table to the ..._entity_int one by using an INSERT / SELECT statement (this query can be a bit long)
update your configurable attributes (not all your attributes, ONLY the ones you know you have created and are use to set configurable products) to set their backend type to int (and never do something else again for configurable selects :) )
delete all entries corresponding to attribute in the ..._entity{attribute} table that you'll no more use (it can do pretty much entries since you can have a lot of products if you get a lot of options)
Here are some MySQL scripts, corresponding to these steps, supposing you have at start a list of the attributes codes concerned :
Check existing entries in entity int for a given list of attribute codes
-- Check existing entries to not duplicate
SELECT ea.attribute_code,
count(*)
FROM eav_attribute as ea
INNER JOIN catalog_product_entity_int as cpei
ON ea.attribute_id = cpei.attribute_id
WHERE ea.attribute_code IN(
{attributeCodesList}
)
GROUP BY ea.attribute_code
Duplicate entries from entity_varchar table (for example) to entity_int for a given list of attribute codes
-- Duplicating missed selects from varchat entity table to int
INSERT INTO catalog_product_entity_int (entity_type_id, attribute_id, store_id, entity_id, value)
SELECT cpev.entity_type_id,
cpev.attribute_id,
cpev.store_id,
cpev.entity_id,
cpev.value
FROM eav_attribute as ea
INNER JOIN catalog_product_entity_varchar as cpev
ON ea.attribute_id = cpev.attribute_id
WHERE ea.attribute_code IN(
{attributeCodesList}
)
Update attributes to never have the problem again!
-- Update missed select attributes from varchar backend type to int one
UPDATE eav_attribute as ea
SET ea.backend_type = 'int'
WHERE ea.attribute_code IN (
{attributeCodesList}
)
Remove the no more used entries from your database
-- Kill old varchar in varchar entity table
DELETE FROM catalog_product_entity_varchar
WHERE attribute_id IN (
SELECT ea.attribute_id
FROM eav_attribute as ea
WHERE ea.attribute_code IN (
{attributeCodesList}
)
)
Hope it will help all of the ones who can't make their associated products show up to get the trick!

Resources