19
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-&...
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 ...
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 ...
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(),'...
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()->...
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 ...
5
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' ...
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,
\...
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:...
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>/...
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
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.
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]/...
3
votes
Accepted
How to show the product attribute in the product listing page Magento 2.3
Method 1:
echo $_product->getAttributeText('manufacturer');
Method 2:
$manufacturer = $_product->getResource()->getAttribute('manufacturer');
echo $manufacturer->getFrontend()->...
2
votes
Configurable product attribute sort order in Dropdown 2.12
In v2.3.x you can sort the order of the attributes by option label in a configurable product drop down selector by extending
Magento\ConfigurableProduct\Model\AttributeOptionProvider
and using
...
2
votes
Accepted
How to enable search for selected dropdown values?
check below code
<div class="search">
<li class="fields">
<label for="technologies"><?php echo $this->__('Technologies'); ?></label>
<?php $url = Mage::getBaseUrl()...
2
votes
Accepted
How to get value of custom dropdown product attribute?
$product = Mage::getModel('catalog/product')->load($item->getProductId());
$product->getAttributeText('soldby');
2
votes
Accepted
getAttributeRawValue gives an id
Try it using getAttributeText() function and this function will only work with the attribute type select
$col=$simp->getAttributeText('manufacturer_color');
getAttributeRawValue() returns the id ...
2
votes
Accepted
Magento 1.9: validate custom attribute
I suggest to use default Magento validation method as below.
Replace
<script type="text/javascript">
// Add our field to the data submitted by Review.save()
Review.prototype.save = Review....
2
votes
Accepted
Magento 2: Get Product Attribute’s Select Option Id as Per Option Value For Configurable Product
You have defined $attr instead of $packaging in your code.
<?php
$packaging =$_product->getResource()->getAttribute('packaging')->getFrontend()->getValue($_product);?>
$...
2
votes
Accepted
How to Show Admin Label in drop down fillter on product grid?
You need to create custom file for add options in dropdown like below way :
<item name="options" xsi:type="object">Vendor\Module\Ui\Component\Listing\Column\Myoptions</item>
You need to ...
2
votes
Accepted
Display product attribute dropdown box value on product page, with custom placement?
See the blocks original template (vendor/magento/module-catalog/view/frontend/templates/product/view/attribute.phtml), especially this condition:
$_attributeType = $block->getAtType();
//[...]
if ($...
1
vote
getAttributeRawValue gives an id
You can use getAttributeText to get product label.
$label = Mage::getModel("catalog/product")->load($simp)->getAttributeText("manufacturer_name");
You can use as per Marius's answer like,
$...
1
vote
Show the SKU in the dropdown of Configurable Products?
I don't think this is possible.
And here is why.
Let's say you have a configurable product with 2 configurable attributes. Size and color. 2 sizes (S, L) and 2 colors (Red, Blue).
So there are 4 ...
1
vote
How to get value of custom dropdown product attribute?
Please try this:
$seller= Mage::getModel('catalog/product')->load($item->getProductId());
$seller->getAttributeText('soldby');
1
vote
How to show the drop down attribute value using getData() method in magento 2?
The answers above were partially missing something (at least for my case, since I needed to use the custom attribute value inside the cart template), if you want to pass the custom attribute to a ...
1
vote
Configurable product attribute sort order in Dropdown 2.12
Because this issue is still present also in the latest release 2.1.7 you can use this workaround:
Go to configurable product page->Configurations->remove all simple products
After that add them ...
1
vote
Configurable product attribute sort order in Dropdown 2.12
If you mean that Newborn is attribute value, you need to go to Stores -> Attributes (Product), find needed attribute and also using drag&drop with your mouse change position of options.
The ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
dropdown-attribute × 176attributes × 52
magento2 × 44
magento-1.9 × 36
product-attribute × 30
configurable-product × 24
product × 12
magento-1.7 × 9
customer-attribute × 8
checkout × 6
magento-1.8 × 6
module × 6
price × 6
magento-2.1 × 5
magento-1 × 5
collection × 5
custom-options × 5
custom-attributes × 5
attribute-set × 5
frontend × 4
filter × 4
product-list × 4
simple-product × 4
multiselect-attribute × 4
drop-downs × 4