Magento - Add / Remove Attributes to Existing Configurable ProductsSelect configurable attributes on an existing productConfigurable product tax issues on asscoaiated products1.7 and configurable productsMagento create configurable product BUT without child products dataConfigurable attributes values in catalog_product_index_eav for configurable product triggered by $product->save()How can I delete configurable product attributes?Need to get Simple Products with Configurable Option from Configurable ProductSimple Products not showing as associated in configurable productsMaking attributes assigned to configurable products optionalcreating Configurable products shows products for only one attributeMagento 2 add simple products to configurable products
Magical attacks and overcoming damage resistance
Nails holding drywall
All ASCII characters with a given bit count
How can I wire a 9-position switch so that each position turns on one more LED than the one before?
"The cow" OR "a cow" OR "cows" in this context
What is the term for a person whose job is to place products on shelves in stores?
What was Apollo 13's "Little Jolt" after MECO?
Why must Chinese maps be obfuscated?
Is Electric Central Heating worth it if using Solar Panels?
Why do distances seem to matter in the Foundation world?
Is there really no use for MD5 anymore?
Is there a better way to say "see someone's dreams"?
Can a Bard use the Spell Glyph option of the Glyph of Warding spell and cast a known spell into the glyph?
My bank got bought out, am I now going to have to start filing tax returns in a different state?
How much of a wave function must reside inside event horizon for it to be consumed by the black hole?
Should the Product Owner dictate what info the UI needs to display?
Drawing a german abacus as in the books of Adam Ries
Unknown code in script
My admission is revoked after accepting the admission offer
Does a large simulator bay have standard public address announcements?
A Note on N!
Are there moral objections to a life motivated purely by money? How to sway a person from this lifestyle?
How to pronounce 'c++' in Spanish
Injection into a proper class and choice without regularity
Magento - Add / Remove Attributes to Existing Configurable Products
Select configurable attributes on an existing productConfigurable product tax issues on asscoaiated products1.7 and configurable productsMagento create configurable product BUT without child products dataConfigurable attributes values in catalog_product_index_eav for configurable product triggered by $product->save()How can I delete configurable product attributes?Need to get Simple Products with Configurable Option from Configurable ProductSimple Products not showing as associated in configurable productsMaking attributes assigned to configurable products optionalcreating Configurable products shows products for only one attributeMagento 2 add simple products to configurable products
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
What is the correct procedure - rather than deleting the product and starting again to add or remove attributes to existing configurable products.
When creating a configurable product you are asked to choose which attributes to use for the product.
I have a lot of products i now need to remove some attributes for that were selected initially, and some that also need an attribute adding that were not initially selected.
Any help with this is appreciated - as deleting the products does not seem like the best approach to this. Especially as lots of other things are associated to the products.
magento-1.7 products-management configurable-product
add a comment |
What is the correct procedure - rather than deleting the product and starting again to add or remove attributes to existing configurable products.
When creating a configurable product you are asked to choose which attributes to use for the product.
I have a lot of products i now need to remove some attributes for that were selected initially, and some that also need an attribute adding that were not initially selected.
Any help with this is appreciated - as deleting the products does not seem like the best approach to this. Especially as lots of other things are associated to the products.
magento-1.7 products-management configurable-product
The correct answer here is: delete the product and create a new one, but there are solutions for this problem (and I think modules) but I think you can google yourself, I don't have a solution for this in mind
– Fabian Blechschmidt
Apr 17 '13 at 13:26
Did you find a solution for this? Is the below answer the solution? Please give an update.
– philwinkle
May 16 '13 at 4:40
I havent tried it yet. But i will be testing this very soon. Thanks a lot for answering - I will mark as answered if it works
– eleven11
May 16 '13 at 12:15
Like i had a color attribute and it was linked with all configurable product.In-case that attribute has been deleted. So that its not finding that linked attribute there & showing an error as "Notice: Undefined offset: 0 in /home/not1son/public_html/vendor/magento/module-configure-product/model/Product/Type/VariationMatrix.php on line 43". Need some help to handle this situation.Thanks in advance.
– Bhagyashree
May 24 '18 at 10:56
add a comment |
What is the correct procedure - rather than deleting the product and starting again to add or remove attributes to existing configurable products.
When creating a configurable product you are asked to choose which attributes to use for the product.
I have a lot of products i now need to remove some attributes for that were selected initially, and some that also need an attribute adding that were not initially selected.
Any help with this is appreciated - as deleting the products does not seem like the best approach to this. Especially as lots of other things are associated to the products.
magento-1.7 products-management configurable-product
What is the correct procedure - rather than deleting the product and starting again to add or remove attributes to existing configurable products.
When creating a configurable product you are asked to choose which attributes to use for the product.
I have a lot of products i now need to remove some attributes for that were selected initially, and some that also need an attribute adding that were not initially selected.
Any help with this is appreciated - as deleting the products does not seem like the best approach to this. Especially as lots of other things are associated to the products.
magento-1.7 products-management configurable-product
magento-1.7 products-management configurable-product
asked Apr 17 '13 at 11:13
eleven11eleven11
3004720
3004720
The correct answer here is: delete the product and create a new one, but there are solutions for this problem (and I think modules) but I think you can google yourself, I don't have a solution for this in mind
– Fabian Blechschmidt
Apr 17 '13 at 13:26
Did you find a solution for this? Is the below answer the solution? Please give an update.
– philwinkle
May 16 '13 at 4:40
I havent tried it yet. But i will be testing this very soon. Thanks a lot for answering - I will mark as answered if it works
– eleven11
May 16 '13 at 12:15
Like i had a color attribute and it was linked with all configurable product.In-case that attribute has been deleted. So that its not finding that linked attribute there & showing an error as "Notice: Undefined offset: 0 in /home/not1son/public_html/vendor/magento/module-configure-product/model/Product/Type/VariationMatrix.php on line 43". Need some help to handle this situation.Thanks in advance.
– Bhagyashree
May 24 '18 at 10:56
add a comment |
The correct answer here is: delete the product and create a new one, but there are solutions for this problem (and I think modules) but I think you can google yourself, I don't have a solution for this in mind
– Fabian Blechschmidt
Apr 17 '13 at 13:26
Did you find a solution for this? Is the below answer the solution? Please give an update.
– philwinkle
May 16 '13 at 4:40
I havent tried it yet. But i will be testing this very soon. Thanks a lot for answering - I will mark as answered if it works
– eleven11
May 16 '13 at 12:15
Like i had a color attribute and it was linked with all configurable product.In-case that attribute has been deleted. So that its not finding that linked attribute there & showing an error as "Notice: Undefined offset: 0 in /home/not1son/public_html/vendor/magento/module-configure-product/model/Product/Type/VariationMatrix.php on line 43". Need some help to handle this situation.Thanks in advance.
– Bhagyashree
May 24 '18 at 10:56
The correct answer here is: delete the product and create a new one, but there are solutions for this problem (and I think modules) but I think you can google yourself, I don't have a solution for this in mind
– Fabian Blechschmidt
Apr 17 '13 at 13:26
The correct answer here is: delete the product and create a new one, but there are solutions for this problem (and I think modules) but I think you can google yourself, I don't have a solution for this in mind
– Fabian Blechschmidt
Apr 17 '13 at 13:26
Did you find a solution for this? Is the below answer the solution? Please give an update.
– philwinkle
May 16 '13 at 4:40
Did you find a solution for this? Is the below answer the solution? Please give an update.
– philwinkle
May 16 '13 at 4:40
I havent tried it yet. But i will be testing this very soon. Thanks a lot for answering - I will mark as answered if it works
– eleven11
May 16 '13 at 12:15
I havent tried it yet. But i will be testing this very soon. Thanks a lot for answering - I will mark as answered if it works
– eleven11
May 16 '13 at 12:15
Like i had a color attribute and it was linked with all configurable product.In-case that attribute has been deleted. So that its not finding that linked attribute there & showing an error as "Notice: Undefined offset: 0 in /home/not1son/public_html/vendor/magento/module-configure-product/model/Product/Type/VariationMatrix.php on line 43". Need some help to handle this situation.Thanks in advance.
– Bhagyashree
May 24 '18 at 10:56
Like i had a color attribute and it was linked with all configurable product.In-case that attribute has been deleted. So that its not finding that linked attribute there & showing an error as "Notice: Undefined offset: 0 in /home/not1son/public_html/vendor/magento/module-configure-product/model/Product/Type/VariationMatrix.php on line 43". Need some help to handle this situation.Thanks in advance.
– Bhagyashree
May 24 '18 at 10:56
add a comment |
6 Answers
6
active
oldest
votes
Here is what seams to work for me for to remove an attribute from the configurable product.
This is the scenario.
All the configurable products were created wrong with the attribute brand
as a configurable attribute for about 50 configurable products having about 200 simple associated products.
All the simple products associated to a configurable attribute have the same brand. The idea is to remove brand
from configurable attributes and assign it as a simple attribute to the configurable product with the value of one of the simple products.
Here is the code that does this. The code is ran one time only. It can be added in an upgrade script or a simple php file.
<?php
//==>this is required only if you use a simple php file
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();
//<==
$brand = 'brand';
//get the attribute instance
$brandAttribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $brand);
//if this attribute exists
if ($brandAttribute->getId())
//make the attribute apply to al types of products in case it's not
$brandAttribute->setApplyTo(null);
$brandAttribute->save();
$resource = Mage::getSingleton('core/resource');
//get an object with access to direct queries
$connection = $resource->getConnection('core_write');
//get all configurable products - you can specify additional filters here
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('type_id', 'configurable');
foreach ($collection as $product)
//the configurable attributes are stored in the table 'catalog_product_super_attribute'
//remove the attribute references from that table.
//The constraints will take care of the cleanup.
$q = "DELETE FROM $resource->getTableName('catalog_product_super_attribute')
WHERE attribute_id = $brandAttribute->getId() AND product_id = $product->getId()";
$connection->query($q);
//get the simple products in the configurable product
$usedProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
foreach ($usedProducts as $p)
//identify the first simple product that has a value for brand
//set that value to the configurable product.
if ($brandValue = $p->getData($brand))
Mage::getSingleton('catalog/product_action')
->updateAttributes(array($product->getId()), array($brand=>$brandValue), 0);
break;
For the numbers listed above, this took about 15 seconds to run on my local machine (not a powerful one). I'm sure that this can be optimized. Most probably there is no need to get all simple products of a configurable product to get the brand
value, but I didn't bother.
2
I hate that it has to be done this way and there is no method to achieve the same thing but thanks for the information.
– webnoob
Aug 18 '14 at 10:44
@Marius, will this work for 1.9?
– Magento Learner
Mar 16 '16 at 8:01
@MagentoLearner. I don't know for sure but I have a hunch it does work.
– Marius♦
Mar 16 '16 at 8:01
@Marius, a very quick reply!!! thanks very much
– Magento Learner
Mar 16 '16 at 8:02
@Marius, Suppose I want to add one super attribute. By adding a row with product_id and attribute_id to the tablecatalog_product_super_attribute
will work? Or else I need to modify other tables? Like in stackoverflow.com/a/13381381/1749007
– Magento Learner
Mar 16 '16 at 9:48
|
show 2 more comments
This requires direct edit of the database, and the first law of Magento is do not directly edit the database.
But if you're crazy enough to proceed, this was covered on StackOverflow a few months back:
ucts. I've tested the below DB workaround hack on CE 1.6.2 and it seems to be working:
- Create attribute
- Drag it to appropriate attribute set
- Go to db editor or phpmyadmin, table ‘catalog_eav_attribute’ and look at the last one, note the ‘attribute id’, also note the product
id -> go to catalog_product_entity and look for the configurable
product you want, and note entity_id -> this is the product_id
- Go to catalog_product_super_attribute and insert new record with product_id and attribute_id, note of the product_super_attribute_id
- Go to catalog_product_super_attribute_label and insert new record with product_super_attribute_id and the value of your new attribute,
like ‘Color’ or ‘Size’ which you used when adding the attribute in the
admin
- Go back to admin and click the configurable product, you will notice none of your child products is associated to your configurable
product.
- Click one of the child products, and select appropriate attribute value, you may also change the sku.
- Export all child products and add the new attribute and sku values to it, import it back and you are done or you may have to manually
change all in the admin without using the dataflow.
Credit: https://stackoverflow.com/questions/5658197/add-new-attribute-to-existing-configurable-product-magento
Untested - YMMV.
add a comment |
To remove one super product attribute (as they are called) from all configurable products, you could execute this SQL query in the database:
DELETE FROM catalog_product_super_attribute
WHERE attribute_id = <id>;
Here, is the id of attribute stored in eav_attribute table regarding attribute_code.
The table catalog_product_super_attribute links products to super product attributes. You can add and remove attributes to create configurable products there.
1
To only remove the super product attribute from a specific single product you can extend the above SQL query to filter also on the product IDDELETE FROM catalog_product_super_attribute WHERE attribute_id = <attribute_id> AND product_id = <product_id>;
– Judder
Oct 20 '17 at 10:24
add a comment |
There is dirty hack to open configurable product then chose duplicate, select old and new attribute, duplicate is made without SKU, then delete original configurable product and simple products. After that you can give same SKU to duplicate. Then you just need to make new simple products.
It's fast workaround if there are not that many simple products.
Not a proper answer
– Deepak Rai
May 10 '16 at 12:11
add a comment |
I have just managed to do this more cleanly using the Free Magmi import export tool in update mode. (understandinge version)
Export key fields, change configurable_attributes column settings to specify configurable attributes on simple and configurable SKUS then reimport using Magmi
As a former Oracle Consultant, I'd agree don't mess with the database, especially one as complex as the Magento data structure - better to use a tool that has been well tested to do this.
add a comment |
I needed to remove an Attribute from being one of the "Configurable" attributes for a Configurable Product.
References above about catalog_product_super_attribute were correct.
Using Navicat database tool I did sequentially a few things.For testing Changed the Attribute_Id, that changed it to another field being
used in other products. (Confirmed that was the record at issue).
Wrote Down, just in case, the full set of record data
(product_super_attribute_id, product_id, attribute_id, position)Finally Deleted the record all together.
That did the trick. I also kept a note of what I did assuming I would need to do this again.
Again: Deleting the Record in "catalog_product_super_attribute" solved my issue which seemed related to others above.
Extra Info: to correlate "attribute_id" to the correct named list it is important to look at:
catalog_super_attribute_label -> and correlate via product_super_attribute_id.
I had been searching for a related "attribute_id" field (yet to find).
"product_super_attribute_id" does the trick for telling you what the "attribute_id" actually is. (I would like to still find the "default" data set for "attribute_id" to see how the an attribute is first defined in the database).
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f3072%2fmagento-add-remove-attributes-to-existing-configurable-products%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is what seams to work for me for to remove an attribute from the configurable product.
This is the scenario.
All the configurable products were created wrong with the attribute brand
as a configurable attribute for about 50 configurable products having about 200 simple associated products.
All the simple products associated to a configurable attribute have the same brand. The idea is to remove brand
from configurable attributes and assign it as a simple attribute to the configurable product with the value of one of the simple products.
Here is the code that does this. The code is ran one time only. It can be added in an upgrade script or a simple php file.
<?php
//==>this is required only if you use a simple php file
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();
//<==
$brand = 'brand';
//get the attribute instance
$brandAttribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $brand);
//if this attribute exists
if ($brandAttribute->getId())
//make the attribute apply to al types of products in case it's not
$brandAttribute->setApplyTo(null);
$brandAttribute->save();
$resource = Mage::getSingleton('core/resource');
//get an object with access to direct queries
$connection = $resource->getConnection('core_write');
//get all configurable products - you can specify additional filters here
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('type_id', 'configurable');
foreach ($collection as $product)
//the configurable attributes are stored in the table 'catalog_product_super_attribute'
//remove the attribute references from that table.
//The constraints will take care of the cleanup.
$q = "DELETE FROM $resource->getTableName('catalog_product_super_attribute')
WHERE attribute_id = $brandAttribute->getId() AND product_id = $product->getId()";
$connection->query($q);
//get the simple products in the configurable product
$usedProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
foreach ($usedProducts as $p)
//identify the first simple product that has a value for brand
//set that value to the configurable product.
if ($brandValue = $p->getData($brand))
Mage::getSingleton('catalog/product_action')
->updateAttributes(array($product->getId()), array($brand=>$brandValue), 0);
break;
For the numbers listed above, this took about 15 seconds to run on my local machine (not a powerful one). I'm sure that this can be optimized. Most probably there is no need to get all simple products of a configurable product to get the brand
value, but I didn't bother.
2
I hate that it has to be done this way and there is no method to achieve the same thing but thanks for the information.
– webnoob
Aug 18 '14 at 10:44
@Marius, will this work for 1.9?
– Magento Learner
Mar 16 '16 at 8:01
@MagentoLearner. I don't know for sure but I have a hunch it does work.
– Marius♦
Mar 16 '16 at 8:01
@Marius, a very quick reply!!! thanks very much
– Magento Learner
Mar 16 '16 at 8:02
@Marius, Suppose I want to add one super attribute. By adding a row with product_id and attribute_id to the tablecatalog_product_super_attribute
will work? Or else I need to modify other tables? Like in stackoverflow.com/a/13381381/1749007
– Magento Learner
Mar 16 '16 at 9:48
|
show 2 more comments
Here is what seams to work for me for to remove an attribute from the configurable product.
This is the scenario.
All the configurable products were created wrong with the attribute brand
as a configurable attribute for about 50 configurable products having about 200 simple associated products.
All the simple products associated to a configurable attribute have the same brand. The idea is to remove brand
from configurable attributes and assign it as a simple attribute to the configurable product with the value of one of the simple products.
Here is the code that does this. The code is ran one time only. It can be added in an upgrade script or a simple php file.
<?php
//==>this is required only if you use a simple php file
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();
//<==
$brand = 'brand';
//get the attribute instance
$brandAttribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $brand);
//if this attribute exists
if ($brandAttribute->getId())
//make the attribute apply to al types of products in case it's not
$brandAttribute->setApplyTo(null);
$brandAttribute->save();
$resource = Mage::getSingleton('core/resource');
//get an object with access to direct queries
$connection = $resource->getConnection('core_write');
//get all configurable products - you can specify additional filters here
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('type_id', 'configurable');
foreach ($collection as $product)
//the configurable attributes are stored in the table 'catalog_product_super_attribute'
//remove the attribute references from that table.
//The constraints will take care of the cleanup.
$q = "DELETE FROM $resource->getTableName('catalog_product_super_attribute')
WHERE attribute_id = $brandAttribute->getId() AND product_id = $product->getId()";
$connection->query($q);
//get the simple products in the configurable product
$usedProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
foreach ($usedProducts as $p)
//identify the first simple product that has a value for brand
//set that value to the configurable product.
if ($brandValue = $p->getData($brand))
Mage::getSingleton('catalog/product_action')
->updateAttributes(array($product->getId()), array($brand=>$brandValue), 0);
break;
For the numbers listed above, this took about 15 seconds to run on my local machine (not a powerful one). I'm sure that this can be optimized. Most probably there is no need to get all simple products of a configurable product to get the brand
value, but I didn't bother.
2
I hate that it has to be done this way and there is no method to achieve the same thing but thanks for the information.
– webnoob
Aug 18 '14 at 10:44
@Marius, will this work for 1.9?
– Magento Learner
Mar 16 '16 at 8:01
@MagentoLearner. I don't know for sure but I have a hunch it does work.
– Marius♦
Mar 16 '16 at 8:01
@Marius, a very quick reply!!! thanks very much
– Magento Learner
Mar 16 '16 at 8:02
@Marius, Suppose I want to add one super attribute. By adding a row with product_id and attribute_id to the tablecatalog_product_super_attribute
will work? Or else I need to modify other tables? Like in stackoverflow.com/a/13381381/1749007
– Magento Learner
Mar 16 '16 at 9:48
|
show 2 more comments
Here is what seams to work for me for to remove an attribute from the configurable product.
This is the scenario.
All the configurable products were created wrong with the attribute brand
as a configurable attribute for about 50 configurable products having about 200 simple associated products.
All the simple products associated to a configurable attribute have the same brand. The idea is to remove brand
from configurable attributes and assign it as a simple attribute to the configurable product with the value of one of the simple products.
Here is the code that does this. The code is ran one time only. It can be added in an upgrade script or a simple php file.
<?php
//==>this is required only if you use a simple php file
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();
//<==
$brand = 'brand';
//get the attribute instance
$brandAttribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $brand);
//if this attribute exists
if ($brandAttribute->getId())
//make the attribute apply to al types of products in case it's not
$brandAttribute->setApplyTo(null);
$brandAttribute->save();
$resource = Mage::getSingleton('core/resource');
//get an object with access to direct queries
$connection = $resource->getConnection('core_write');
//get all configurable products - you can specify additional filters here
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('type_id', 'configurable');
foreach ($collection as $product)
//the configurable attributes are stored in the table 'catalog_product_super_attribute'
//remove the attribute references from that table.
//The constraints will take care of the cleanup.
$q = "DELETE FROM $resource->getTableName('catalog_product_super_attribute')
WHERE attribute_id = $brandAttribute->getId() AND product_id = $product->getId()";
$connection->query($q);
//get the simple products in the configurable product
$usedProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
foreach ($usedProducts as $p)
//identify the first simple product that has a value for brand
//set that value to the configurable product.
if ($brandValue = $p->getData($brand))
Mage::getSingleton('catalog/product_action')
->updateAttributes(array($product->getId()), array($brand=>$brandValue), 0);
break;
For the numbers listed above, this took about 15 seconds to run on my local machine (not a powerful one). I'm sure that this can be optimized. Most probably there is no need to get all simple products of a configurable product to get the brand
value, but I didn't bother.
Here is what seams to work for me for to remove an attribute from the configurable product.
This is the scenario.
All the configurable products were created wrong with the attribute brand
as a configurable attribute for about 50 configurable products having about 200 simple associated products.
All the simple products associated to a configurable attribute have the same brand. The idea is to remove brand
from configurable attributes and assign it as a simple attribute to the configurable product with the value of one of the simple products.
Here is the code that does this. The code is ran one time only. It can be added in an upgrade script or a simple php file.
<?php
//==>this is required only if you use a simple php file
error_reporting(E_ALL | E_STRICT);
$mageFilename = 'app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app();
//<==
$brand = 'brand';
//get the attribute instance
$brandAttribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $brand);
//if this attribute exists
if ($brandAttribute->getId())
//make the attribute apply to al types of products in case it's not
$brandAttribute->setApplyTo(null);
$brandAttribute->save();
$resource = Mage::getSingleton('core/resource');
//get an object with access to direct queries
$connection = $resource->getConnection('core_write');
//get all configurable products - you can specify additional filters here
$collection = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('type_id', 'configurable');
foreach ($collection as $product)
//the configurable attributes are stored in the table 'catalog_product_super_attribute'
//remove the attribute references from that table.
//The constraints will take care of the cleanup.
$q = "DELETE FROM $resource->getTableName('catalog_product_super_attribute')
WHERE attribute_id = $brandAttribute->getId() AND product_id = $product->getId()";
$connection->query($q);
//get the simple products in the configurable product
$usedProducts = $product->getTypeInstance(true)->getUsedProducts(null, $product);
foreach ($usedProducts as $p)
//identify the first simple product that has a value for brand
//set that value to the configurable product.
if ($brandValue = $p->getData($brand))
Mage::getSingleton('catalog/product_action')
->updateAttributes(array($product->getId()), array($brand=>$brandValue), 0);
break;
For the numbers listed above, this took about 15 seconds to run on my local machine (not a powerful one). I'm sure that this can be optimized. Most probably there is no need to get all simple products of a configurable product to get the brand
value, but I didn't bother.
answered Oct 1 '13 at 7:33
Marius♦Marius
168k28324694
168k28324694
2
I hate that it has to be done this way and there is no method to achieve the same thing but thanks for the information.
– webnoob
Aug 18 '14 at 10:44
@Marius, will this work for 1.9?
– Magento Learner
Mar 16 '16 at 8:01
@MagentoLearner. I don't know for sure but I have a hunch it does work.
– Marius♦
Mar 16 '16 at 8:01
@Marius, a very quick reply!!! thanks very much
– Magento Learner
Mar 16 '16 at 8:02
@Marius, Suppose I want to add one super attribute. By adding a row with product_id and attribute_id to the tablecatalog_product_super_attribute
will work? Or else I need to modify other tables? Like in stackoverflow.com/a/13381381/1749007
– Magento Learner
Mar 16 '16 at 9:48
|
show 2 more comments
2
I hate that it has to be done this way and there is no method to achieve the same thing but thanks for the information.
– webnoob
Aug 18 '14 at 10:44
@Marius, will this work for 1.9?
– Magento Learner
Mar 16 '16 at 8:01
@MagentoLearner. I don't know for sure but I have a hunch it does work.
– Marius♦
Mar 16 '16 at 8:01
@Marius, a very quick reply!!! thanks very much
– Magento Learner
Mar 16 '16 at 8:02
@Marius, Suppose I want to add one super attribute. By adding a row with product_id and attribute_id to the tablecatalog_product_super_attribute
will work? Or else I need to modify other tables? Like in stackoverflow.com/a/13381381/1749007
– Magento Learner
Mar 16 '16 at 9:48
2
2
I hate that it has to be done this way and there is no method to achieve the same thing but thanks for the information.
– webnoob
Aug 18 '14 at 10:44
I hate that it has to be done this way and there is no method to achieve the same thing but thanks for the information.
– webnoob
Aug 18 '14 at 10:44
@Marius, will this work for 1.9?
– Magento Learner
Mar 16 '16 at 8:01
@Marius, will this work for 1.9?
– Magento Learner
Mar 16 '16 at 8:01
@MagentoLearner. I don't know for sure but I have a hunch it does work.
– Marius♦
Mar 16 '16 at 8:01
@MagentoLearner. I don't know for sure but I have a hunch it does work.
– Marius♦
Mar 16 '16 at 8:01
@Marius, a very quick reply!!! thanks very much
– Magento Learner
Mar 16 '16 at 8:02
@Marius, a very quick reply!!! thanks very much
– Magento Learner
Mar 16 '16 at 8:02
@Marius, Suppose I want to add one super attribute. By adding a row with product_id and attribute_id to the table
catalog_product_super_attribute
will work? Or else I need to modify other tables? Like in stackoverflow.com/a/13381381/1749007– Magento Learner
Mar 16 '16 at 9:48
@Marius, Suppose I want to add one super attribute. By adding a row with product_id and attribute_id to the table
catalog_product_super_attribute
will work? Or else I need to modify other tables? Like in stackoverflow.com/a/13381381/1749007– Magento Learner
Mar 16 '16 at 9:48
|
show 2 more comments
This requires direct edit of the database, and the first law of Magento is do not directly edit the database.
But if you're crazy enough to proceed, this was covered on StackOverflow a few months back:
ucts. I've tested the below DB workaround hack on CE 1.6.2 and it seems to be working:
- Create attribute
- Drag it to appropriate attribute set
- Go to db editor or phpmyadmin, table ‘catalog_eav_attribute’ and look at the last one, note the ‘attribute id’, also note the product
id -> go to catalog_product_entity and look for the configurable
product you want, and note entity_id -> this is the product_id
- Go to catalog_product_super_attribute and insert new record with product_id and attribute_id, note of the product_super_attribute_id
- Go to catalog_product_super_attribute_label and insert new record with product_super_attribute_id and the value of your new attribute,
like ‘Color’ or ‘Size’ which you used when adding the attribute in the
admin
- Go back to admin and click the configurable product, you will notice none of your child products is associated to your configurable
product.
- Click one of the child products, and select appropriate attribute value, you may also change the sku.
- Export all child products and add the new attribute and sku values to it, import it back and you are done or you may have to manually
change all in the admin without using the dataflow.
Credit: https://stackoverflow.com/questions/5658197/add-new-attribute-to-existing-configurable-product-magento
Untested - YMMV.
add a comment |
This requires direct edit of the database, and the first law of Magento is do not directly edit the database.
But if you're crazy enough to proceed, this was covered on StackOverflow a few months back:
ucts. I've tested the below DB workaround hack on CE 1.6.2 and it seems to be working:
- Create attribute
- Drag it to appropriate attribute set
- Go to db editor or phpmyadmin, table ‘catalog_eav_attribute’ and look at the last one, note the ‘attribute id’, also note the product
id -> go to catalog_product_entity and look for the configurable
product you want, and note entity_id -> this is the product_id
- Go to catalog_product_super_attribute and insert new record with product_id and attribute_id, note of the product_super_attribute_id
- Go to catalog_product_super_attribute_label and insert new record with product_super_attribute_id and the value of your new attribute,
like ‘Color’ or ‘Size’ which you used when adding the attribute in the
admin
- Go back to admin and click the configurable product, you will notice none of your child products is associated to your configurable
product.
- Click one of the child products, and select appropriate attribute value, you may also change the sku.
- Export all child products and add the new attribute and sku values to it, import it back and you are done or you may have to manually
change all in the admin without using the dataflow.
Credit: https://stackoverflow.com/questions/5658197/add-new-attribute-to-existing-configurable-product-magento
Untested - YMMV.
add a comment |
This requires direct edit of the database, and the first law of Magento is do not directly edit the database.
But if you're crazy enough to proceed, this was covered on StackOverflow a few months back:
ucts. I've tested the below DB workaround hack on CE 1.6.2 and it seems to be working:
- Create attribute
- Drag it to appropriate attribute set
- Go to db editor or phpmyadmin, table ‘catalog_eav_attribute’ and look at the last one, note the ‘attribute id’, also note the product
id -> go to catalog_product_entity and look for the configurable
product you want, and note entity_id -> this is the product_id
- Go to catalog_product_super_attribute and insert new record with product_id and attribute_id, note of the product_super_attribute_id
- Go to catalog_product_super_attribute_label and insert new record with product_super_attribute_id and the value of your new attribute,
like ‘Color’ or ‘Size’ which you used when adding the attribute in the
admin
- Go back to admin and click the configurable product, you will notice none of your child products is associated to your configurable
product.
- Click one of the child products, and select appropriate attribute value, you may also change the sku.
- Export all child products and add the new attribute and sku values to it, import it back and you are done or you may have to manually
change all in the admin without using the dataflow.
Credit: https://stackoverflow.com/questions/5658197/add-new-attribute-to-existing-configurable-product-magento
Untested - YMMV.
This requires direct edit of the database, and the first law of Magento is do not directly edit the database.
But if you're crazy enough to proceed, this was covered on StackOverflow a few months back:
ucts. I've tested the below DB workaround hack on CE 1.6.2 and it seems to be working:
- Create attribute
- Drag it to appropriate attribute set
- Go to db editor or phpmyadmin, table ‘catalog_eav_attribute’ and look at the last one, note the ‘attribute id’, also note the product
id -> go to catalog_product_entity and look for the configurable
product you want, and note entity_id -> this is the product_id
- Go to catalog_product_super_attribute and insert new record with product_id and attribute_id, note of the product_super_attribute_id
- Go to catalog_product_super_attribute_label and insert new record with product_super_attribute_id and the value of your new attribute,
like ‘Color’ or ‘Size’ which you used when adding the attribute in the
admin
- Go back to admin and click the configurable product, you will notice none of your child products is associated to your configurable
product.
- Click one of the child products, and select appropriate attribute value, you may also change the sku.
- Export all child products and add the new attribute and sku values to it, import it back and you are done or you may have to manually
change all in the admin without using the dataflow.
Credit: https://stackoverflow.com/questions/5658197/add-new-attribute-to-existing-configurable-product-magento
Untested - YMMV.
edited May 23 '17 at 12:37
Community♦
1
1
answered Apr 22 '13 at 4:54
philwinklephilwinkle
33.5k583144
33.5k583144
add a comment |
add a comment |
To remove one super product attribute (as they are called) from all configurable products, you could execute this SQL query in the database:
DELETE FROM catalog_product_super_attribute
WHERE attribute_id = <id>;
Here, is the id of attribute stored in eav_attribute table regarding attribute_code.
The table catalog_product_super_attribute links products to super product attributes. You can add and remove attributes to create configurable products there.
1
To only remove the super product attribute from a specific single product you can extend the above SQL query to filter also on the product IDDELETE FROM catalog_product_super_attribute WHERE attribute_id = <attribute_id> AND product_id = <product_id>;
– Judder
Oct 20 '17 at 10:24
add a comment |
To remove one super product attribute (as they are called) from all configurable products, you could execute this SQL query in the database:
DELETE FROM catalog_product_super_attribute
WHERE attribute_id = <id>;
Here, is the id of attribute stored in eav_attribute table regarding attribute_code.
The table catalog_product_super_attribute links products to super product attributes. You can add and remove attributes to create configurable products there.
1
To only remove the super product attribute from a specific single product you can extend the above SQL query to filter also on the product IDDELETE FROM catalog_product_super_attribute WHERE attribute_id = <attribute_id> AND product_id = <product_id>;
– Judder
Oct 20 '17 at 10:24
add a comment |
To remove one super product attribute (as they are called) from all configurable products, you could execute this SQL query in the database:
DELETE FROM catalog_product_super_attribute
WHERE attribute_id = <id>;
Here, is the id of attribute stored in eav_attribute table regarding attribute_code.
The table catalog_product_super_attribute links products to super product attributes. You can add and remove attributes to create configurable products there.
To remove one super product attribute (as they are called) from all configurable products, you could execute this SQL query in the database:
DELETE FROM catalog_product_super_attribute
WHERE attribute_id = <id>;
Here, is the id of attribute stored in eav_attribute table regarding attribute_code.
The table catalog_product_super_attribute links products to super product attributes. You can add and remove attributes to create configurable products there.
edited Oct 20 '17 at 10:45
Judder
1144
1144
answered Oct 8 '16 at 11:00
Abhinav SinghAbhinav Singh
2,145612
2,145612
1
To only remove the super product attribute from a specific single product you can extend the above SQL query to filter also on the product IDDELETE FROM catalog_product_super_attribute WHERE attribute_id = <attribute_id> AND product_id = <product_id>;
– Judder
Oct 20 '17 at 10:24
add a comment |
1
To only remove the super product attribute from a specific single product you can extend the above SQL query to filter also on the product IDDELETE FROM catalog_product_super_attribute WHERE attribute_id = <attribute_id> AND product_id = <product_id>;
– Judder
Oct 20 '17 at 10:24
1
1
To only remove the super product attribute from a specific single product you can extend the above SQL query to filter also on the product ID
DELETE FROM catalog_product_super_attribute WHERE attribute_id = <attribute_id> AND product_id = <product_id>;
– Judder
Oct 20 '17 at 10:24
To only remove the super product attribute from a specific single product you can extend the above SQL query to filter also on the product ID
DELETE FROM catalog_product_super_attribute WHERE attribute_id = <attribute_id> AND product_id = <product_id>;
– Judder
Oct 20 '17 at 10:24
add a comment |
There is dirty hack to open configurable product then chose duplicate, select old and new attribute, duplicate is made without SKU, then delete original configurable product and simple products. After that you can give same SKU to duplicate. Then you just need to make new simple products.
It's fast workaround if there are not that many simple products.
Not a proper answer
– Deepak Rai
May 10 '16 at 12:11
add a comment |
There is dirty hack to open configurable product then chose duplicate, select old and new attribute, duplicate is made without SKU, then delete original configurable product and simple products. After that you can give same SKU to duplicate. Then you just need to make new simple products.
It's fast workaround if there are not that many simple products.
Not a proper answer
– Deepak Rai
May 10 '16 at 12:11
add a comment |
There is dirty hack to open configurable product then chose duplicate, select old and new attribute, duplicate is made without SKU, then delete original configurable product and simple products. After that you can give same SKU to duplicate. Then you just need to make new simple products.
It's fast workaround if there are not that many simple products.
There is dirty hack to open configurable product then chose duplicate, select old and new attribute, duplicate is made without SKU, then delete original configurable product and simple products. After that you can give same SKU to duplicate. Then you just need to make new simple products.
It's fast workaround if there are not that many simple products.
answered Oct 22 '15 at 23:09
DinkoDinko
191
191
Not a proper answer
– Deepak Rai
May 10 '16 at 12:11
add a comment |
Not a proper answer
– Deepak Rai
May 10 '16 at 12:11
Not a proper answer
– Deepak Rai
May 10 '16 at 12:11
Not a proper answer
– Deepak Rai
May 10 '16 at 12:11
add a comment |
I have just managed to do this more cleanly using the Free Magmi import export tool in update mode. (understandinge version)
Export key fields, change configurable_attributes column settings to specify configurable attributes on simple and configurable SKUS then reimport using Magmi
As a former Oracle Consultant, I'd agree don't mess with the database, especially one as complex as the Magento data structure - better to use a tool that has been well tested to do this.
add a comment |
I have just managed to do this more cleanly using the Free Magmi import export tool in update mode. (understandinge version)
Export key fields, change configurable_attributes column settings to specify configurable attributes on simple and configurable SKUS then reimport using Magmi
As a former Oracle Consultant, I'd agree don't mess with the database, especially one as complex as the Magento data structure - better to use a tool that has been well tested to do this.
add a comment |
I have just managed to do this more cleanly using the Free Magmi import export tool in update mode. (understandinge version)
Export key fields, change configurable_attributes column settings to specify configurable attributes on simple and configurable SKUS then reimport using Magmi
As a former Oracle Consultant, I'd agree don't mess with the database, especially one as complex as the Magento data structure - better to use a tool that has been well tested to do this.
I have just managed to do this more cleanly using the Free Magmi import export tool in update mode. (understandinge version)
Export key fields, change configurable_attributes column settings to specify configurable attributes on simple and configurable SKUS then reimport using Magmi
As a former Oracle Consultant, I'd agree don't mess with the database, especially one as complex as the Magento data structure - better to use a tool that has been well tested to do this.
answered Oct 31 '16 at 2:30
Dave BDave B
1
1
add a comment |
add a comment |
I needed to remove an Attribute from being one of the "Configurable" attributes for a Configurable Product.
References above about catalog_product_super_attribute were correct.
Using Navicat database tool I did sequentially a few things.For testing Changed the Attribute_Id, that changed it to another field being
used in other products. (Confirmed that was the record at issue).
Wrote Down, just in case, the full set of record data
(product_super_attribute_id, product_id, attribute_id, position)Finally Deleted the record all together.
That did the trick. I also kept a note of what I did assuming I would need to do this again.
Again: Deleting the Record in "catalog_product_super_attribute" solved my issue which seemed related to others above.
Extra Info: to correlate "attribute_id" to the correct named list it is important to look at:
catalog_super_attribute_label -> and correlate via product_super_attribute_id.
I had been searching for a related "attribute_id" field (yet to find).
"product_super_attribute_id" does the trick for telling you what the "attribute_id" actually is. (I would like to still find the "default" data set for "attribute_id" to see how the an attribute is first defined in the database).
add a comment |
I needed to remove an Attribute from being one of the "Configurable" attributes for a Configurable Product.
References above about catalog_product_super_attribute were correct.
Using Navicat database tool I did sequentially a few things.For testing Changed the Attribute_Id, that changed it to another field being
used in other products. (Confirmed that was the record at issue).
Wrote Down, just in case, the full set of record data
(product_super_attribute_id, product_id, attribute_id, position)Finally Deleted the record all together.
That did the trick. I also kept a note of what I did assuming I would need to do this again.
Again: Deleting the Record in "catalog_product_super_attribute" solved my issue which seemed related to others above.
Extra Info: to correlate "attribute_id" to the correct named list it is important to look at:
catalog_super_attribute_label -> and correlate via product_super_attribute_id.
I had been searching for a related "attribute_id" field (yet to find).
"product_super_attribute_id" does the trick for telling you what the "attribute_id" actually is. (I would like to still find the "default" data set for "attribute_id" to see how the an attribute is first defined in the database).
add a comment |
I needed to remove an Attribute from being one of the "Configurable" attributes for a Configurable Product.
References above about catalog_product_super_attribute were correct.
Using Navicat database tool I did sequentially a few things.For testing Changed the Attribute_Id, that changed it to another field being
used in other products. (Confirmed that was the record at issue).
Wrote Down, just in case, the full set of record data
(product_super_attribute_id, product_id, attribute_id, position)Finally Deleted the record all together.
That did the trick. I also kept a note of what I did assuming I would need to do this again.
Again: Deleting the Record in "catalog_product_super_attribute" solved my issue which seemed related to others above.
Extra Info: to correlate "attribute_id" to the correct named list it is important to look at:
catalog_super_attribute_label -> and correlate via product_super_attribute_id.
I had been searching for a related "attribute_id" field (yet to find).
"product_super_attribute_id" does the trick for telling you what the "attribute_id" actually is. (I would like to still find the "default" data set for "attribute_id" to see how the an attribute is first defined in the database).
I needed to remove an Attribute from being one of the "Configurable" attributes for a Configurable Product.
References above about catalog_product_super_attribute were correct.
Using Navicat database tool I did sequentially a few things.For testing Changed the Attribute_Id, that changed it to another field being
used in other products. (Confirmed that was the record at issue).
Wrote Down, just in case, the full set of record data
(product_super_attribute_id, product_id, attribute_id, position)Finally Deleted the record all together.
That did the trick. I also kept a note of what I did assuming I would need to do this again.
Again: Deleting the Record in "catalog_product_super_attribute" solved my issue which seemed related to others above.
Extra Info: to correlate "attribute_id" to the correct named list it is important to look at:
catalog_super_attribute_label -> and correlate via product_super_attribute_id.
I had been searching for a related "attribute_id" field (yet to find).
"product_super_attribute_id" does the trick for telling you what the "attribute_id" actually is. (I would like to still find the "default" data set for "attribute_id" to see how the an attribute is first defined in the database).
edited 5 hours ago
answered 5 hours ago
L ArnoldL Arnold
292
292
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f3072%2fmagento-add-remove-attributes-to-existing-configurable-products%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
The correct answer here is: delete the product and create a new one, but there are solutions for this problem (and I think modules) but I think you can google yourself, I don't have a solution for this in mind
– Fabian Blechschmidt
Apr 17 '13 at 13:26
Did you find a solution for this? Is the below answer the solution? Please give an update.
– philwinkle
May 16 '13 at 4:40
I havent tried it yet. But i will be testing this very soon. Thanks a lot for answering - I will mark as answered if it works
– eleven11
May 16 '13 at 12:15
Like i had a color attribute and it was linked with all configurable product.In-case that attribute has been deleted. So that its not finding that linked attribute there & showing an error as "Notice: Undefined offset: 0 in /home/not1son/public_html/vendor/magento/module-configure-product/model/Product/Type/VariationMatrix.php on line 43". Need some help to handle this situation.Thanks in advance.
– Bhagyashree
May 24 '18 at 10:56