Skip to content

Instantly share code, notes, and snippets.

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 zainengineer/d76a678865f0e96ebd5595f4067f0b08 to your computer and use it in GitHub Desktop.
Save zainengineer/d76a678865f0e96ebd5595f4067f0b08 to your computer and use it in GitHub Desktop.
//had NO EFFECT
$iStoreId = 9;
class_exists('\Kint',false) && (\Kint::$max_depth =3);
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
/** @var \Magento\Store\Model\StoreManagerInterface $storeManager */
$storeManager =$objectManager->create('\Magento\Store\Model\StoreManagerInterface');
//has NO EFFECT
$storeManager->setCurrentStore($iStoreId);
/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepo */
$productRepo = $objectManager->create('\Magento\Catalog\Api\ProductRepositoryInterface');
/** @var \Magento\Framework\Api\SearchCriteriaBuilder $criteriaBuilder */
$criteriaBuilder = $objectManager->create('Magento\Framework\Api\SearchCriteriaBuilder');
$criteriaBuilder->setPageSize(10);
/** @var \Magento\Framework\Api\SearchCriteria $criteria */
$criteria = $criteriaBuilder->create();
$list = $productRepo->getList($criteria);
$readableList = [];
foreach ($list->getItems() as $product) {
$simple = $product->getData();
$readableList[] = $simple;
}
return $readableList;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment