I want to update product information for "All Store Views" but it seems that when I try to update a product, Magento ignores setStoreId(0)
. Instead the product information will be saved to store view 1.
For reference I have 4 store views: 1, 2, 3, 4 + store view 0 (admin).
My code:
$collection = $this->filter->getCollection($this->collectionFactory->create());
foreach ($collection->getAllIds() AS $productId)
{
$product = $this->productRepository->getById($productId);
$product->setStoreId(0);
$product->setSpecialPrice(111);
$this->productRepository->save($product);
}