Today we’ll talk about how we can get store specific products name and descriptions. Like for example, my shop has six store views: DE, AT, IT, ES, FR, and GB. And each store view uses the same set of the product with appropriately translated but I would for example want to view a product in a specific view like DE.
We can do that just by following the instructions below:
public function __construct(\Magento\Catalog\Model\ProductFactory $productFactory) {
$this->productFactory = $productFactory;
}
now you can use this like,
Where $storeIdis your store Id and
$pidis your product Id.
Don’t forget to do
by
and clearcache
Product Repository
public function __construct( \Magento\Catalog\Api\ProductRepositoryInterface $productRepository )
{
$this->productRepository = $productRepository;
}
Now, you can use below
$productName=$product->getName();
You can see It’s arguments invendor\magento\module-catalog\Api\ProductRepositoryInterface.phppublic function getById($productId, $editMode = false, $storeId = null, $forceReload =
So, what do you think ?