New answers tagged

0

Follow This Step :- 1. Navigate to Stores > Attributes > Product in Magento admin panel. 2. Search for the needed attribute (the attribute you want to add to the layered navigation) and click on it to Edit it. 3. In Storefront Properties tab > Use in Layered Navigation select Filterable (with results). 4. Set Use in Search Results ...


0

Solution 1 : (Not a good approach, but my last solution ) to print Product attribute values Separately like 100g,1 Litter,1k etc.. using Object manager $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $item = $this->getItem(); $productFactory = $objectManager->create('\Magento\Catalog\Model\...


1

Please Try This code to add Product attribute to Programatically . with possible options. $eavSetup->addAttribute( \Magento\Catalog\Model\Product::ENTITY, 'custom_dropdown', [ 'type' => 'varchar', 'label' => 'Custom Dropdown', 'input' => 'multiselect', 'required' => false, 'backend' => '...


0

You need to set "use in product listing" option from manage attributes For Magento2 Store -> Attributes -> Products For Magento 1.4+ Catalog -> Attributes -> Manage Attributes Edit your attribute. In Storefront Properties tab select Used in Product Listing to "Yes" then check again after reindex


2

If it is a dropdown attribute then use this: $_item->getProduct()->getAttributeText('weight_spices'); or $_item->getProduct()->getResource()->getAttributeRawValue($this->getProduct()->getId(),'weight_spices',$this->_storeManager->getStore()->getId()); rest of the attributes could be get by this: $_item->getProduct()->...


2

As you have using Api interface, So, you have to add hide_address as an extension attribute of Magento\Customer\Api\Data\AddressInterface. Create a <Module>/etc/extension_attributes.xml file to define a hide_address extension attribute. <?xml version="1.0"?> <!-- /** * * @author Amit Bera * @copyright Copyright (c) 2018-2020 amitbera.com ...


1

By default magento store the category attributes with the store id. So each category attributes can be save store wise. In case of custom attributes, may some problem with the creation of attribute. You can go with below article which has a good knowledge base to create the category attribute. https://www.yereone.com/blog/magento-2-how-to-add-new-category-...


0

First try to get attribute :- $category_id = 20; $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $_category = $objectManager->create('Magento\Catalog\Model\Category')->load($category_id); print($_category->getData('custom_attribute')); After this, use media class to show image.


1

Please Try my way I get Category custom attribute image name homepage_image <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface'); $mediaUrl = $storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); $catId = ...


0

You can try using object manager $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $category = $objectManager->get('Magento\Framework\Registry')->registry('current_category');//get current category $catCustomAttImg = $category->getData('cat_custom_att_img'); if (!empty($catCustomAttImg)) { echo '<img src="' . $...


0

Try This :- print_r($customers->getCustomAttributes('enable_alerts')->getValue());


0

Please check "is_global" property in the database table catalog_eav_attribute for your custom attribute and make sure it is having value as 0. Then after your custom attribute one checkbox will appear "Use Default Value" in the admin. Unchecking that checkbox will help you to save attribute value store view level.


2

<?php namespace Test\Customer\Setup; use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Customer\Setup\CustomerSetupFactory; use Magento\Customer\Model\Customer; use Magento\Eav\Model\Entity\Attribute\SetFactory as AttributeSetFactory; /*...


3

1) Update module setup version in module.xml file. like setup_version="1.1.0" 2) Create file CustomerSetup.php into Setup/ directory. <?php namespace Vendor\ModuleName\Setup; use Magento\Eav\Setup\EavSetup; use Magento\Eav\Setup\EavSetupFactory; use Magento\Framework\Setup\UpgradeDataInterface; use Magento\Framework\Setup\ModuleContextInterface; ...


3

Can you please mention which magento version you are using because i found it is known bug and get resolved in magento 2.2.x https://github.com/magento/magento2/issues/7844


0

Note: I have not tried it yet but it should work. To show the SKU value in the product view page, /vendor/magento/module-catalog/view/frontend/templates/product/view/attribute.phtml file is called. In this file you will find code like below: $_call = $block->getAtCall(); $_code = $block->getAtCode(); which basically gets the values from the default ...


0

I found the solution. First create new file at this path : magento/vendor/magento/module_catelog/view/frontend/templates/product/view/attributes_productpage.phtml code: <?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ // @codingStandardsIgnoreFile /** * Product additional attributes template ...


1

Magento opensource version does not have the feature to add customer attribute from admin just like Product. If you want to add a custom attribute to registration form then you have to do coding or use any extension. You can follow below link for adding a custom attribute to the registration form. Magento 2 - Add custom attribute in customer registration ...


0

How to remove an attribute from attribute sets So, you've accidentally added an attribute to all attribute sets? You can remove it from the unwanted attribute sets, without deleting the attribute, and keep it in the attribute set you want. You can also remove the unwanted group at the same time. In your UpgradeData script: // Remove the attribute from ...


0

How to create a product attribute and add it to only 1 attribute set When you create a product attribute in Magento 2, you have to ensure 2 things in the array you give to addAttribute(): Do not specify a group key. We'll see later how to add the attribute to the group. You have to specify 'user_defined' => true, Otherwise, Magento will add the ...


0

Here goes composer.json { "name": "xigen/module-customer", "description": "", "type": "magento2-module", "license": "proprietary", "authors": [ { "name": "name", "email": "email@email.com" } ], "minimum-stability": "dev", "require": {}, "autoload": { "psr-4": { "...


0

You need to filter that editor content using cms page filter. in your block class Try following way: public function __construct( \Magento\Cms\Model\Template\FilterProvider $filterProvider) { $this->_filterProvider = $filterProvider; } Now use $this->_filterProvider->getPageFilter()->filter($content);


0

Try to this Code to get attribute Value in Magento 2. $_getMyAttr = $_product->getResource()->getAttribute('my_attribute'); // Get Value $attrTestValue = $_getMyAttr->getFrontend()->getValue($_product); // Get Label $attrTestLabel = $_getMyAttr->getStoreLabel();


0

I'm using color attribute here, you can use below function in your block file: /* $this->productModel is Magento\Catalog\Model\Product;*/ public function getColorValue($optionId){ $colorValue = ''; if($optionId) { $attribute = $this->productModel->getResource()->getAttribute('color'); if ($attribute->usesSource()) { ...


Top 50 recent answers are included