Skip to content

Instantly share code, notes, and snippets.

@tvthu
Created July 20, 2022 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tvthu/133d59870ac76753c01f0de02900a743 to your computer and use it in GitHub Desktop.
Save tvthu/133d59870ac76753c01f0de02900a743 to your computer and use it in GitHub Desktop.
Test magento 2
<?php
ini_set('display_errors', 1);
ini_set('max_execution_time', 0);
ini_set("memory_limit", "-1");
set_time_limit(0);
error_reporting(E_ALL);
require './app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$productRepo = $objectManager->get('\Magento\Catalog\Model\ProductRepository');
$StockState = $objectManager->get('\Magento\InventorySalesAdminUi\Model\GetSalableQuantityDataBySku');
/**
* @var \Magento\Catalog\Model\Product $product
*/
$product = $productRepo->getById('58227');
// $product = $productRepo->getById('58226');
// echo json_encode($StockState->execute( $product->getSku()), 1);
echo json_encode($product->isSalable());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment