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

2
  • Upload your code please. Jul 26, 2019 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'); Jul 26, 2019 at 8:36

2 Answers 2

1

Please try with below code :

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

OR

$_product->setEpaisseur($namep);

I hope its helpful to you.

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

Try this,

$value="test";
$product->setEpaisseur(trim($value));
$product->getResource()->saveAttribute($product, 'epaisseur');
1
  • 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 Jul 29, 2019 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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