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

3 REPLIES 3

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.

 

 

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

Hello @raza19 ,

If You are changing description of particular product via coding then please add all the information related to check sku or id is correct or not on based on you are updating.
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.


you have to setup storeview in which you want to save data because by default it get stored in default store view.

Reindex: Sometimes, changes to product data may not reflect immediately due to indexing. Try reindexing your Magento installation to ensure that the product data is up to date. You can do this from the command line using the bin/magento indexer:reindex command.

Check for ErrorsCheck your logs for any errors that might indicate why the product description isn't being saved correctly. Look for any exceptions related to saving product data.

 

If you still have any questions you can contact us.