Created
April 5, 2016 00:27
-
-
Save vmasciotta/d6e74499b4c191f77145b0e4a0a2c4c7 to your computer and use it in GitHub Desktop.
Magento2 Sandbox
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('display_errors', 1); | |
ini_set('display_startup_errors', 1); | |
error_reporting(E_ALL); | |
//echo "hello world"; | |
try { | |
require __DIR__ . '/app/bootstrap.php'; | |
} catch (\Exception $e) { | |
echo $e->getMessage(); | |
exit(1); | |
} | |
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); | |
$appState = $bootstrap->getObjectManager()->get('Magento\Framework\App\State'); | |
$appState->setAreaCode('en'); | |
//your code here | |
/** @var Magento\Catalog\Model\ResourceModel\Product\Collection $collection */ | |
$collection = $bootstrap->getObjectManager()->get('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory')->create(); | |
$collection->addStoreFilter() | |
->addAttributeToSelect('*') | |
->addAttributeToFilter('price',['gt'=>30]) | |
->setPageSize(10) | |
->load(); | |
echo '<pre>'; | |
foreach ($collection as $product) { | |
echo $product->getName() . ' ' . $product->getPrice() . '<br/>'; | |
} | |
echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment