Skip to content

Instantly share code, notes, and snippets.

@bka
Created May 29, 2017 19:29
Show Gist options
  • Save bka/b42ba0ec7f70993f484d88f658623634 to your computer and use it in GitHub Desktop.
Save bka/b42ba0ec7f70993f484d88f658623634 to your computer and use it in GitHub Desktop.
Iterate magento2 products
$objectManager = $this->getObjectManager();
$appState = $objectManager->get('Magento\Framework\App\State');
$appState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMINHTML);
$productCollection = $objectManager->create("\Magento\Catalog\Model\ResourceModel\Product\Collection");
$productCollection->addAttributeToSelect('*');
foreach ($productCollection as $product) {
var_dump($product->getData());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment