cancel
Showing results for 
Search instead for 
Did you mean: 

updating product description via coding correctly shows text on product page but admin side is blank

SOLVED

updating product description via coding correctly shows text on product page but admin side is blank

In my custom module, I am able to set the description of an existing product successfully using the code below & the product url shows correct output for description:

$product = $this->productRepository->get('q783');
$product->setData('description','hello world');
$this->productRepository->save($product);

However, this programmatically saved description doesn't show up on the admin side rather the edit with page builder form for description shows old values. When you try to update the description using page builder from the browser after having updated it once via php code, the browser edited form does in fact show newer values on the admin side but there is no change on the product url's description despite multiple cache refreshes and reindexing.

 

Is this expected behavior? Do I need to store description using php code in a different manner so that the saved shows up in edit with page builder section for description on the admin side?

 

As it stands now, both php code set and manually filled description using edit with page builder are out of sync albeit the actual product url is continuously showing php code set descriptions, no matter how many times I update the product form via browser with newer description values in page builder.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: updating product description via coding correctly shows text on product page but admin side is b

That's because in admin you're probably looking at the value under "All store views", while programatically you probably saved the product description value in a more specific store view scope.

 

So open up the product in admin and in the top left switch from All store views to specific store view and you should see you description there.

Founder at https://agency418.com

View solution in original post

2 REPLIES 2

Re: updating product description via coding correctly shows text on product page but admin side is b

That's because in admin you're probably looking at the value under "All store views", while programatically you probably saved the product description value in a more specific store view scope.

 

So open up the product in admin and in the top left switch from All store views to specific store view and you should see you description there.

Founder at https://agency418.com

Re: updating product description via coding correctly shows text on product page but admin side is b

Spent an entire day trying to make it work Smiley Happy First time anyone has truly tried to help on this forum & that was some spot on advice, thank you .

 

So, when I open the product for editing it opens with "All Store Views" scope but the code is updating "Default Store View". When I switch to the latter in the browser, the page builder is indeed showing the code-updated text.