1

I have created custom attribute to product called thickness and i set visible in catalog product to yes but still getting null of this attribute

I am going to store / product and created a new attribute then i set the value of my attribute as below

$_product->setCustomAttribute('epaisseur', $namep);

and then i called the attribute in my phtml :

$epaisseur = $_product->getData('epaisseur'); 

any help please

  • Upload your code please. – Rohan Hapani Jul 26 at 8:33
  • I just go to stores/ product and created a new attribute then i set the value of my attribute as below $_product->setCustomAttribute('epaisseur', $namep); and then i called the attribute in my phtml : $epaisseur =$_product->getData('epaisseur'); – Developper Magento Jul 26 at 8:36
1

Please try with below code :

$_product->setData('epaisseur', $namep);

OR

$_product->setEpaisseur($namep);

I hope its helpful to you.

  • i tried and nothing changed still getteing null – Developper Magento Jul 26 at 10:10
  • please check $namep, are you getting value or not. if yes than please share your whole function - code. – Anas Mansuri Jul 26 at 11:13
  • yes and i can find the value in db – Developper Magento Jul 26 at 12:15
  • try with $_product->setEpaisseur($namep); – Anas Mansuri Jul 26 at 12:30
1

Try this,

$value="test";
$product->setEpaisseur(trim($value));
$product->getResource()->saveAttribute($product, 'epaisseur');
  • i just used sql request and i get the value but no one of this solution worked for me thanks a lot for your replay MSA – Developper Magento Jul 29 at 8:09

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.