Magento specific attribute per category - php

I want to only display specific attribute to specific type of product. For example I have Shoes and a footID. footID will only be available in Shoes product page and not any other. In time I'll also have a few more similar attributes for example tennisID that only applies to tennis Products.

In order to achieve this you first have to create all the different attributes you need. (Such as footID and tennisID)
After that you have to create multiple attribute sets. In your example you would have to create two attribute sets called "Shoes" and "Tennis".
In each of these attribute sets you add the attributes that belong to them. (Example when creating the attribute set tennis you have to add (drag) the tennisID attribute to it. (same goes for the shoes attribute set)
These attributes will only be visible (both frontend and backend) for the attribute sets they have been added too.
Regards,
Kenny

Related

Combine same attributes with different slug - Woocommerce

I have multiple product attributes with the same name and same terms but different slugs. That's a result of a migration from Shopify to Woocommerce. For example, attribute 'Μέγεθος'('Size' in Greek) entered 2000 times for each product. Now i don't know how to combine those to one attribute with all terms like S,M,L,XL,44,45,56 etc.
Unless i edit product attributes one by one, is there a most sufficient option? Any suggestion?
Screenshot

Convert WooCommerce Custom Product Attributes into Defined Product Attributes

I am trying to filter ~30,000 products in a WooCommerce store using WooCommerce's Layered Nav attribute filter sidebar widget. This requires the use of a pre-defined product attribute taxonomy, as opposed to using custom attributes on a per-product basis.
Each product in the store has an imported custom 'Brand' attribute. Prior to importing products, I created an attribute taxonomy called 'Brand' (pa_brand) in wp-admin. However, imported products have not had their Brand attribute (and term name) added to the Brand (pa_brand) taxonomy. Instead, all of the products have a custom attribute called 'Brand' not linked to the pa_brand taxonomy.
Does anyone know how to convert custom product attributes into defined attributes within the pre-defined taxonomy (with terms not yet created)?
I assume that I'd need to run a PHP script which does the following, but don't know if I've missed any steps out:
Obtain an array of ID's for all of the products in the database
Loop over each of the product ID's (foreach)
get_attributes() from each product ID - this will return the custom 'Brand' attribute (there are no pa_brand assignments yet)
Check: If the brand term already exists in the pa_brand taxonomy, do nothing; if it doesn't, add the term to the pa_brand taxonomy
Assign the product to the term within the pa_brand taxonomy
Delete the old custom Brand product attribute
I'm not sure how best to execute this, so any help would be very much appreciated.
PS: to illustrate the distinction between 'custom attributes' and attributes defined in a taxonomy, I have added 2 screenshots below of how they differ when editing a product in WooCommerce. Note how the name of the attribute can be altered if not from the defined taxonomy.
Attributes defined in taxonomy:
Custom attributes:
Thanks
It looks like someone has done this before - https://gist.github.com/birgire/0ed300ae4436fcaf508c
just to help anyone that comes to this page sharing the same problem. Custom attribute to global (taxonomy), variations, etc...
How we solved it easily:
We created the same name of the Custom Attribute as a Global Attribute (Brand => Brand). No need to add terms, just attribute Name.
Downloaded (Export) all the products as CSV file on the All Products table page.
On the CSV file (opened on Excel) make sure to set Attribute n global (n is the number of attribute, 1, 2, etc...) to 1 (when it's custom it will show 0). Do this on all rows that have the attribute you are converting.
To make sure Variations also saved and that attribute can be used make sure that Attribute n visible is also set to 1 on all rows.
Save the file.
Next go back to your All Products page and click on Import.
Choose the file and check the box that says "Existing products that match by ID or SKU will be updated. Products that do not exist will be skipped.".
Next click on Run the importer button.
This will convert all the custom attributes with their terms into global, and also keep all the variations. No need for any coding or hard work.
For the steps 3 and 4 you can use formula like this one =IF(AN2="Flavors","1","") for the first line and copy paste it to all rows to do it automatically for a specific attribute if needed.
Hopefully this will help you.

Relational Dropdown/Select product attributes in Magento backend

I'm developing a Magento store for a vehicle accessory company. There are a number of vehicle specific items that need Make/Model/Year attributes, however I can't find an extension that allows creation of relational attribute dropdowns - I need three dropdowns, whose options change dynamically depending on the previous dropdown selection, for example:
Dropdown A has four Vehicle Makes. Choosing a Make then populates the Model dropdown with a specific set of options and so on for the Year dropdown.
Is this possible in Magento? I've looked at some of the Make/Model/Year extensions, but they're all text inputs - too much room for input error by staff members. I've also tried VehicleFits but it isn't working/throws a lot of errors and it appears development has ceased.
I've searched high and low, any help would be greatly appreciated.
It's not possible to create dependent product attributes directly or straight forwardly under Manage Attributes. But you can make your attributes depend on each other by creating Configurable products.
Lets say you have 2 colors (black and blue) and 2 sizes (L,XL) and you want to make your colors depend on sizes.
At first create 2 attributes size and color of type dropdown under Manage attributes and create the attribute options and values. and Assign it to the right attribute set.
Now create the simple products , lets say product A with size L and color Black and product B with color Blue and size XL.
Now create a configurable product lets say AB and associate these two simple products A and B. Save the product.
If the customer opens the product AB and if they choose size L they can find only color Black. This is how you can make your product attributes dependent on each other.
Source: here
Or may be this is what you are looking for:
http://www.magentocommerce.com/magento-connect/dependent-custom-options-configurable.html
Hope it helps.

How to include manufacturer description without using a product attribute in Magento Community Edition? PHP / XML / MySQL

In a normalized database schema, the manufacturers would have their own attributes like, for example, name, description, address, phone number.
The manufacturer description is something that is useful for the product pages. Many ecommerce sites show a manufacturer description on every product page.
As far as I know, in Magento you would have to create a product attribute, "Manufacturer description" or something like that. If, for example, ABC Corporation has 1,000 products, you would have to update all 1,000 every time you changed your description for ABC Corporation.
Is that the only reasonably easy way to do it?
Or is there a more database normal way of doing it, where a single, atomic update would result in all the manufacturer's items showing an updated value on the front end?
Create a module with the following contents:
setup script that creates a manufacturer table like desired
model and resource model classes for manufacturer
grid to manage the manufacturers (this is quite complicated, you should follow a tutorial like this or copy the basics from another module)
manufacturer block and template to render HTML for manufacturer info. You will use it as frontend model for the manufacturer_id attribute (see below)
setup script that adds a product attribute manufacturer_id
source model for the manufacturer id, so you can select the manufacturer from a dropdown instead of typing in the id
To display manufacturer description on product page without using product attribute you need to create new table "manufacturer_info" and this table contains information of manufacturer id as well as description.
Table is something like this
manufacturer_id | description
To add description, you need to create new module which will display all the shop brand s and description in grid. When you edit manufacture one form will appear and in that form add description and save it to database.
After saving description, You can display it on product page based on manufacture_id.
To get current manufacture use following code
$_product = $this->getProduct();
$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();
Use manufacturer_id for getting description from newly created table
I hope this helps.

In Magento, is there a way to remove attribute from configurable product after already created?

In Magento, I have have a bunch of configurable products already created and now have a client that has changed their mind and wants to remove one of the attributes. I'm having a hard time figuring out how to do this b/c I keep getting an error message saying:
This attribute is used in configurable
products. You cannot remove it from
the attribute set.
I have tried going into the attribute and changing Use to Create Configurable Product from "yes" to "no", but that didn't seem to do anything when trying to remove attribute from existing products
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>
The table catalog_product_super_attribute links products to super product attributes. You can add and remove attributes to created configurable products there.
It seems like you're trying to remove the attribute from the attribute set first, but you need to remove it from the configurable products, then the attribute set. Open each configurable product, go to the Associated Products tab and remove the attribute (and linked products) that is not required. Save each product and then try removing the attribute from the set.
Simply use phpmyadmin and connect to your database.
Look for the eav_attribute table.
Delete the attribute you want.
may be this could help:
http://www.magentocommerce.com/boards/viewthread/6059/#t327478
Unfortunately, this is not possible from the standard Magento backend.
As such, you have to look at SQL solutions (I'm not familair with these).
Building on Christian Davén's answer, you could use the following to delete based on the attribute_code name instead of the attribute_id itself, just to be sure that you are referencing the right ID:
DELETE FROM `catalog_product_super_attribute`
WHERE `attribute_id` IN (
SELECT `attribute_id` FROM `eav_attribute`
WHERE `attribute_code` = "attribute"
)

Categories