18 votes
Accepted

How to show the drop down attribute value using getData() method in magento 2?

Instead of getData() you need to use getAttributeText('attribute_code') for dropdown attributes. like $_product->getAttributeText('material'); For multi-select try this : $result = $_product-&...
user avatar
14 votes
Accepted

Configurable product attribute sort order in Dropdown 2.12

I faced the same attribute options sorting issue at front-end, As I checked this issue and found that while fetching the attribute options, there is no sorting filter added in the query by default in ...
user avatar
11 votes

How do I remove the +$0.00 from product bundle options?

Go to the file: app/design/frontend/base/default/template/bundle/catalog/product/view/type/bundle/option/ Choose your selection method: I am writing the below code for select.phtml The simple ...
user avatar
8 votes
Accepted

Magento 2 - Set simple product Color when creating product programmatically

$attr = $_product->getResource()->getAttribute('color'); $avid = $attr->getSource()->getOptionId('Blue'); //name in Default Store View $_product->setData('color', $avid); I found the answer from here ...
user avatar
8 votes

How to show the drop down attribute value using getData() method in magento 2?

You can get product attribute option values by below code $_product->getAttributeText('material'); You can get multi select option values by $_attributeValue = $block->getProduct()->...
user avatar
8 votes

How to show the drop down attribute value using getData() method in magento 2?

To fetch value of attribute Use: $this->getProduct()->getAttributeText('material'); Or $this->getProduct()->getResource()->getAttributeRawValue($this->getProduct()->getId(),'...
user avatar
7 votes
Accepted

Swap Multiple Images with Configurable Swatches

I have built this, in a modular way. Will post the code on github soon. It triggers on a JavaScript call and fetches the images with Ajax. So it does not effect page speed or caching system. PM me ...
user avatar
7 votes

How to show "Out of Stock" text in dropdown option?

To show out of stock products go to System > Configuration > Catalog > Inventory and set Display Out of Stock Products to yes. Now we'll need to rewrite the class ...
user avatar
  • 37.4k
7 votes
Accepted

Create Product Attribute Of Type MULTISELECT or dropdown select & Create Option Labels Diffrent for Diffrent Store using install or upgrade schema

I have check the core how magento install the label and I found code in below file vendor/magento/module-eav/Setup/EavSetup.php in this file I got addAttributeOption method. After seeing the ...
user avatar
6 votes

Swap Multiple Images with Configurable Swatches

And Magento community to the rescue! See https://twitter.com/willemwigman/status/543047966752538624 & https://github.com/wigman/AjaxSwatches. This Module adds an Ajax event to the new ...
user avatar
  • 16.6k
6 votes
Accepted

How to create custom dropdown attribute for customer in magento

Try this: <?php require_once('app/Mage.php'); Mage::app('default'); $installer = new Mage_Customer_Model_Entity_Setup('core_setup'); $installer->startSetup(); $entityTypeId = (int)$...
user avatar
  • 9,552
5 votes
Accepted

How to add new Option to drop down attributes magento2?

Try following way: protected $eavAttributeFactory; protected $attributeOptionManagement; public function __construct( \Magento\Eav\Model\Entity\AttributeFactory $eavAttributeFactory, \...
user avatar
  • 34.4k
5 votes
Accepted

Add a drop-down field in checkout form Magento 2

Step 1: Create module.xml app/code/Vendor/CheckoutAdditionalField/etc/module.xml <?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
user avatar
  • 5,144
4 votes

Swap Multiple Images with Configurable Swatches

I recommend you this extension. One of its features is what you need. It allows you to change the whole media section when you change the color (or any other attribute) displaying the images for the ...
user avatar
  • 196k
4 votes

Default value of 'yes/no' dropdown custom product attribute

I had the problem that with the code snippets above a select-attribute was created instead of a yes/no attribute. To fix this I had to use 'input' => 'boolean' instead of: 'input' ...
user avatar
4 votes

Best Practices for Planning Attributes and Attribute Sets

Obviously reuse attributes between attribute sets where it makes sense. The key with attributes is to strike a balance between the number of attributes and attribute options. Its no good having a ...
user avatar
  • 954
4 votes
Accepted

Magento 2 : Display dropdown attribute with its label in product listing page

For that, you need to override renderer.phtml file and need to change onlySwatches and enableControlLabel attributes value. Go to app/design/frontend/<VendorName>/<themeName>/...
user avatar
  • 16.6k
3 votes

Creating a Customer Attribute set by Dropdown Populated from a table

You just need an attribute with a custom source model. Here is an example on how to create an attribute with custom options. It's for products but the idea is similar. You said you know how to create ...
user avatar
  • 196k
3 votes
Accepted

Getting dropdown attribute value when using addAttributeToSelect

I assume that you are firstly using Mage_Catalog_Model_Resource_Product_Collection and not simply the resource as stated in your question. Now I am also assuming that you are looping through the ...
user avatar
3 votes

New Product DROPDOWN Attribute (IF THEN ELSE)

I'd use a switch statement instead like this. <?php switch ($this->htmlEscape($_item->getAttributeText('etickettype')) { case 'GREEN': $color="GREEN"; ...
user avatar
3 votes

Programmatically import products and set custom attribute value

Your code looks like there are PHP syntax errors. For example: ->setCategoryIds(array(3, 11)) $data=array( 'afmeting' => '180 x 100', 'afwerkingblad '=> 'Havanna', '...
user avatar
  • 503
3 votes

Dropdown for weight

You should use Configurable product with weight attribute variation. Catalog -> Attributes -> Manage Attributes -> Add New Attribute "Meat Weight" The attribute should be drop-down, Use To Create ...
user avatar
3 votes
Accepted

How to add a custom dropdown category attribute in the admin and front end? For magento 1.9

try like this in installer script, <?php $installer = $this; $installer->startSetup(); //First Remove the custom attribute this after install again $nameAttribute = array( 'type' => '...
user avatar
  • 3,931
3 votes
Accepted

How to filter product collection with configurable product attributes

Figured it out by myself. Above code returns nothing because attribute (size) is assigned only to simple products (associated products) and all simple product's visibility is set to 1 i.e, not ...
user avatar
  • 651
3 votes
Accepted

set custom dropdown attribute for customer

You did not create Customer attribute properly. As you have create a dropdown Customer attribute so you need to define source model for this attribute. "source" => "[module_Model_Prefix]/...
user avatar
  • 75.9k
3 votes

Configurable product attribute sort order in Dropdown 2.12

Go to Configurable product page -> Edit Configuration -> Click next -next - next and don't change anything Then save the product and they should be in order.
user avatar
3 votes

How to show the drop down attribute value using getData() method in magento 2?

$_product->getAttributeText('material'); is the right answer --- beware that $_product->getResource() is a deprecated function
user avatar
  • 14.4k
2 votes

Drop down attribute: "Please use letters only"

Edit the attribute you created and check Input Validation for Store Owner, I guess you will not be able to change its value, either delete it and create again and this time select none for validation ...
user avatar
  • 1,973
2 votes

Remove Country Dropdown at Frontend

You can remove the dropdown by selecting only one country in the admin, but there is no actual way to remove it completely since its a required attribute for the customer object.
user avatar
  • 7,333
2 votes

Implementing a dropdown on magento navigation

The core implementation of Magento only does a single-level of navigation (that is either a horizontal or vertical bar, no sub-menus). To change this you need to override the Link block to allow ...
user avatar
  • 1,842

Only top scored, non community-wiki answers of a minimum length are eligible