1

I created a few custom attributes and I want to assign them directly when I import a product programmatically.

The first one I created is called ProductEmbroideryV2 Enable Embroidery.

To turn this one on via my crons script I use embroidery I use this line

$mpProductInfo['embroidery_enabled'] = 1;

Now I created another attribute called Sale/Clearance/New, which has a drop-down of sale, clearance and new.

I want to set any new product I have to get the new tag but I can't figure out how to call that specific attribute. When you check the attributes details it should be sale_clearance but setting any position whether 0,1,2,3 it doesn't get assigned to anything.

Does anyone know what table I can use to find the attributes call tag or a line of code to use to call that attribute and set it to position 3 or the new tag?

Here is some of the code

$mpProductInfo['qty'] = $mp['physical_qty'] + $mp['dropship_qty'];
$mpProductInfo['in_stock'] = 1;
$mpProductInfo['status'] = 1;
$mpProductInfo['visibility'] = Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH;
$mpProductInfo['price'] = $mp['price'];
$mpProductInfo['categories'] = array(2072);
$mpProductInfo['categories'] = array(2107);



$mpProductInfo['sale_clearance'] = 3;

$mpProductInfo['embroidery_enabled'] = 1;



$mpProductInfo['image'] = $mediaDir.'/catalog/product/wysiwyg/FullSizeImages/'.$mp['sku'].'.jpg';
$mpProductInfo['imagePath'] = '/wysiwyg/FullSizeImages/'.$mp['sku'].'.jpg';
$mpProductInfo['image_exists'] = 0;
$mpProductInfo['embroidery_enabled'] = 0;
$mpProductInfo['embroidery_position_enabled'] = 0;
$mpProductInfo['new_size_chart'] = trim($mp['size_chart']);
$mpProductInfo['sizeId'] = 0;

it's the line that is $mpProductInfo['sale_clearance'] = 3;

sale_clearance isn't the right call tag and i dont know what it should be or where to find the correct tag for it.

enter image description here enter image description here enter image description here

enter image description here

  • 1
    I can't really follow - what do you want to achieve exactly? Can you please show some more of your code? What Magento version are you referring to? And maybe a screen shot of your attribute as I honestly can not figure out what all this embroidery-stuff is about in this scenario. – Christoph Farnleitner Jan 3 '18 at 16:13
  • sorry i'm pretty new to this, essentially the goal is to set an attribute called Sale/Clearance/New to new whenever I import a new product. My embroidery attribute works fine but my new one does not. below are pictures of the attributes i'm using and the code that works fine besides line 74. and it's magento 1.9 i believe – Mike Jan 3 '18 at 17:56
  • please add the code and screen in your question itself so we can try to find a solution :) – Christoph Farnleitner Jan 3 '18 at 18:08
  • i added pictures and as you can see the attribute code is sale_clearance so if i set the sale_clearance to position 3 it should add the new tag to new products I import. but sale_clearance is not the correct tag and i dont know what it would be called to set that attribute correctly via the import script i have – Mike Jan 3 '18 at 18:23
1

You can not assign an attribute's option by it's position number. I think the easiest would be to get the option Id (= value) from within product edit view (or from the attribute itself): enter image description here

$mpProductInfo['sale_clearance'] = $option-id;

Basically it's the same like with $mpProductInfo['status'] = 1; which you got already - 1 is the value of the option 'Enabled' in the attribute 'Status' - 2 would be Disabled: enter image description here

You can also get the option Id programmatically - there are many posts on this here on SE. For example:Get Attribute option Id by Attribute admin value

  • 1
    Hey just wanted to say thank you! Using the information you told me with a slight tweek I was able to resolve my issue and setup products with the custom attributes I created, so thank you! – Mike Jan 16 '18 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.