I have idea we can set product status using following code in magento 1.x.but I’m not able to identify in magento 2.0 beta. i'm spending lot of time to search status.php file. i find following file.but no use.


$productid=10;// product id which you want to change status; 
    Mage::getModel('catalog/product_status')->updateProductStatus($productid, $storeid, Mage_Catalog_Model_Product_Status::STATUS_ENABLED);

1 Answer 1


You'll want to use \Magento\Catalog\Api\ProductRepositoryInterface

Declare a dependency on it by adding it to your constructor

    public function __construct(
    \Magento\Catalog\Api\ProductRepositoryInterface $productRepository
) {
    $this->productRepository = $productRepository;

Then you can update the status and save it back with the following code in your method

    $product = $this->productRepository->getById($productId);
  • thanks for ur response.status is website scope.how to set website wise?
    – sivakumar
    May 4, 2015 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.