There is possible to have different product name and description because these attributes have store_view scope. Please take a look at screenshot store_view

To update product programmatically code should be something like:

$sku = 'sku1';
$storeId = 0;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$_product = $obj->create('\Magento\Catalog\Api\ProductRepositoryInterface')->get($sku,true, $storeId, true);

$_product->setShortDescription('short description');
$_product->setCustomAttribute("abc", 'abc');

But in that case product short_description attribute will be updated in all scopes.
How to update product in selected store_view scope?

  • 1
    change $storeId = 0; to $storeId = ...your store id here...; – Marius Aug 19 '20 at 14:42

Please try this below:

$sku = 'sku1';
$storeId = 0;
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Model\Product')->loadByAttribute('sku', $sku);

$attribute_code = 'short_description';
$value = 'short description';

$product->addAttributeUpdate($attribute_code, $value, $storeId);
  • This will update "store" scope, but not "store_view" scope. – Dmitrij Rebrov Aug 21 '20 at 7:27

Either change the store ID like @Dimitri suggested, or switch to the csv uploader. I find that to be the easiest option for bulk updating attributes. All you need to use a CSV is 2 columns, one with the sku, and other with the attribute that you want to update

  • I aware of that CSV import possibility, but use custom product import and need some solution for multilanguage product import. – Dmitrij Rebrov Aug 21 '20 at 7:32

In case somebody will have same issue (please ignore incorrect object injection):

        $sku = '7550055';
        $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
        $_product = $obj->create('\Magento\Catalog\Api\ProductRepositoryInterface')->get($sku);
        $_product->setName('Russian name');
        $_product->setData('store_view_code', 'russian');
        $_product->setData('description', 'russian description');

Take a note if product previously created without store_view_code field - attributes will be changed in all store_view scopes of current store.

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.