Follow the below code to programatically update name of category in a specific store in Magento 2.
public function __construct(
private \Magento\Catalog\Api\CategoryRepositoryInterface $categoryRepository,
private \Magento\Framework\App\Filesystem\DirectoryList $directoryList,
private \Magento\Store\Model\StoreManagerInterface $storeManager
)
...................
$category = $this->categoryRepository->get(120, 2);
$category->setName(trim("test value"));
$this->storeManager->setCurrentStore(2);
$this->categoryRepository->save($category);
Did this post help you?
Tutsplanet brings in-depth and easy tutorials to understand even for beginners. This takes a considerable amount of work. If this post helps you, please consider supporting us as a token of appreciation:
- Just want to thank us? Buy us a Coffee
- May be another day? Shop on Amazon using our links.
Your prices won't change but we get a small commission.
Leave a Reply