15

Try to set default value as string 'default' => '0' or empty 'default' => '' Update The default values are added when you add new product for old ones it not affects. Try to fix that in Product management with mass action Inside manage products, there is a action called “Update Attributes”. Select all the products that you want to update and ...


15

Instead of getData() you need to use getAttributeText('attribute_code') for dropdown attributes. like $_product->getAttributeText('material'); For multi-select try this : $result = $_product->getResource()->getAttribute('material')->getFrontend()->getValue($_product);


14

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 Magento 2.1.2, So to fix this issue need to add the below code to add the ORDER By in function getAttributeOptions on line no 282 in file: vendor/magento/module-...


11

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 process is to change (see the code in bold): <?php if ($this->_showSingle()): ?> <?php echo $this->getSelectionTitlePrice($_selections[0]) ?&...


8

$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 for a simple product. I post here the code because the post I am referring to does not point out which Product Attribute value should be used.


7

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 if you want the code asap. Otherwise follow me on Twitter @willemwigman to hear when I post the code. Edit: I've put the code on github https://github.com/...


7

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 Mage_Catalog_Block_Product_View_Type_Configurable which you can do in your own module. Specifically the method getJsonConfig. This method actually outputs a javascript string that is ...


7

To fetch value of attribute Use: $this->getProduct()->getAttributeText('material'); Or $this->getProduct()->getResource()->getAttributeRawValue($this->getProduct()->getId(),'material',$this->_storeManager->getStore()->getId());


7

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 code I got your answer, create attribute like below You can create multiselect and dropdown attribute option label different on store basis like below $...


6

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 ColorSwatches in Magento 1.9.1.0 When the event ConfigurableMediaImages.updateImage fires up, the original updateImage() function is executed. After this we make an ...


6

Try this: <?php require_once('app/Mage.php'); Mage::app('default'); $installer = new Mage_Customer_Model_Entity_Setup('core_setup'); $installer->startSetup(); $entityTypeId = (int)$installer->getEntityTypeId('customer'); $attributeSetId = (int)$installer->getDefaultAttributeSetId($entityTypeId); $attributeGroupId = (int)$installer->...


6

You can get product attribute option values by below code $_product->getAttributeText('material'); You can get multi select option values by $_attributeValue = $block->getProduct()->getResource()->getAttribute('sizing_guidelines')->getFrontend()->getValue($block->getProduct());


5

Try following way: protected $eavAttributeFactory; protected $attributeOptionManagement; public function __construct( \Magento\Eav\Model\Entity\AttributeFactory $eavAttributeFactory, \Magento\Eav\Api\AttributeOptionManagementInterface $attributeOptionManagement ) { $this->eavAttributeFactory = $eavAttributeFactory; $this->...


5

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:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="Vendor_CheckoutAdditionalField" setup_version="2.0.0"> <sequence>...


4

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' => 'select'


4

It currently can't be done without rewriting Magento code. That attribute on the backend has a specific model it uses The model is located here: Mage_Catalog_Model_Product_Attribute_Source_Countryofmanufacture Looking at the logic in the model, it doesn't even call or mention what products are in that specific category. Going further into the Abstract, ...


4

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 single colour attribute if you have 3000 options for it. Similarly, its a waste if you have 300 attributes for colour, with only 10 options in each. The thing ...


4

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 simple product. See the documentation for the configuration to see how you can achieve this. The extension was build for versions between 1.7 and 1.9.0.1. It ...


3

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 results of your collection. foreach($collection as $product) {} Once you have the product object you can call the function getAttributeText and specify the ...


3

I'd use a switch statement instead like this. <?php switch ($this->htmlEscape($_item->getAttributeText('etickettype')) { case 'GREEN': $color="GREEN"; break; case 'RED': $color="RED"; break; case 'BLUE': $color="BLUE"; break; default: ...


3

Try this: $lastId = $setup->getConnection()->lastInsertId(); $attr = Mage::getModel('eav/entity_attribute_option') ->getCollection() ->setStoreFilter() ->addFieldToFilter('tsv.value_id',array('eq'=>$lastId)) ->getFirstItem(); $optionId = $attr->getData('option_id'); return $optionId;


3

You can use something like this. $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', "your attribute_code"); $arg_value = "your text based label"; foreach ( $attribute->getSource()->getAllOptions(true, true) as $option ) { if($arg_value == $option['label']) { unset($attribute); ...


3

Magento already has a block that displays the attributes in the view page. It is called Mage_Catalog_Block_Product_View_Attributes. See this as demo (additional information section). All the attributes that have is_visible_on_front are displayed in that section. The only down side is that it shows event he attributes that don't have a value. To overcome ...


3

This line is incorrect wich causes the problem: if($_product->getAttributeText($_specialPriceStoreLabel['hide_special_price']) == "Yes") Use like this: if($_product->getHideSpecialPrice()) or if($_product->getData('hide_special_price')) And your attribute hide_special_price should be "Used in Product Listing" and "Visible on Product View Page ...


3

You can directly access your custom attribue of product. Mage::getResourceModel(‘catalog/product’)->getAttributeRawValue($product_id, $attribute_code, $store_id) Or you can Directly use <?php $productGift = Mage::getModel('catalog/product')->load($giftId); $productGift->getYourAttribueName(); ?> Suppose you want color attribute then $...


3

You should set value for all existing entity manually: $productIds = Mage::getResourceModel('catalog/product_collection') ->getAllIds(); // Now create an array of attribute_code => values $attributeData = array("my_attribute_code" =>"my_attribute_value"); // Set the store to affect. I used admin to change all default values $storeId = 0; // ...


3

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 attributes. Well...do your magic and just fill in the source setting of the attribute with your model alias. The model that you use as source must contain a ...


3

Your code looks like there are PHP syntax errors. For example: ->setCategoryIds(array(3, 11)) $data=array( 'afmeting' => '180 x 100', 'afwerkingblad '=> 'Havanna', 'afwerkingonderstel '=> 'Blank'); Also, when you call $Simpleproduct->setData($data); you're replacing the data on the product instance. I think you want to do: $...


3

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 Configurable Product & Global. Create all options under this attribute like 500g, 1000g, ..., 12000g Now Create a Configurable product with attribute "Meat ...


3

try like this in installer script, <?php $installer = $this; $installer->startSetup(); //First Remove the custom attribute this after install again $nameAttribute = array( 'type' => 'varchar', 'label'=> 'Enable Brand link', 'input' => 'select', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, '...


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