Magento – Quick Simple Product Creation: Add new Custom Attribute of MultiSelect each time When I Want to Add New Simple Product

configurable-productcustom-attributesmagento-1.9simple-product

I’ve got a moderately specific question. I’d like to add a new field to the Quick simple product creation section, in associated products, when creating configurable products.

Here’s why (so if there is a better way to do this, please let me know): I have an attribute that needs to be set for every one of my products. Setting it as a configurable product would be convenient, but I do not want this attribute visible at all to customers, or required by customers. It’s a secondary condition category. So, if an item is ConditionA: new, it will also be ConditionB: new. I only want the customer to see the ConditionA settings, because ConditionB is essentially ConditionA, but with numbers instead of a text description, for exporting my products to ebay.

So if a customer wants a used product for example, they can pick used as a configurable option on my store. “condition” would be “used”. But The associated simple product, the “used” product if you will, also has an “ebay_condition” of “3000”, the ebay code for used.

I had this set up fine as a configurable product attribute, realized my customers would have to not only see the ebay settings on my store, but would have to pick an option] when purchasing, and removed it. I now have the attribute set as a dropdown, but non-configurable product attribute.

I want to be able to just “quick simple product creation” generate the associated simple products, with this attribute as well. Other attributes already included in the quick simple generation include… Name, SKU (both set to autogenerate), Weight, Status, Visibility, Condition, Package Status, Quantity, and Stock Availability.

Now, is there a specific setting I have to apply to the ebay_condition attribute to make it appear under Quick simple product creation, just like Visiblity, Weight, SKU, etc., or alternatively can I manually code it in?

Best Answer

So the quick create form can be found at Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Super_Config_Simple and it has a nice and simple check for adding attributes.

Firstly what it does is loads all attributes that are for the product type simple and are attached to the attribute set chosen for your configurable product.

$attributes = Mage::getModel('catalog/product')
    ->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
    ->setAttributeSetId($this->_getProduct()->getAttributeSetId())
    ->getAttributes();

Nice!

Then what it does is loops through all of these attributes and add an input for each that match some settings.

if (($attribute->getIsRequired()
    && $attribute->getApplyTo()
    // If not applied to configurable
    && !in_array(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE, $attribute->getApplyTo())
    // If not used in configurable
    && !in_array($attribute->getId(),
        $this->_getProduct()->getTypeInstance(true)->getUsedProductAttributeIds($this->_getProduct()))
    )
    // Or in additional
    || in_array($attribute->getAttributeCode(), $attributesConfig['additional'])
) {

Yikes!

But basically what these checks are is as follows.

  1. Attribute is required,
  2. Attribute is applied to simply products but not configurable products,
  3. Attribute is not already attached to the configurable product,
  4. Or attribute is part of the blocks "core" attributes that must always be set from this form,

So simply if your attributes are set-up correctly they should appear in this form.

Nice and simply like

Related Topic