Skip to content

Instantly share code, notes, and snippets.

@andrewdaluz
Last active March 24, 2020 00:08
Show Gist options
  • Save andrewdaluz/9956e266b12e7b4305039048125d0356 to your computer and use it in GitHub Desktop.
Save andrewdaluz/9956e266b12e7b4305039048125d0356 to your computer and use it in GitHub Desktop.
Bootstrap Magento 2 script
<?php

use Magento\Framework\App\Bootstrap;

require __DIR__ . '/app/bootstrap.php';

$params = $_SERVER;

$bootstrap = Bootstrap::create(BP, $params);

$obj = $bootstrap->getObjectManager();
 
$state = $obj->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
 
$quoteId = 1;
$quote = $obj->get('Magento\Checkout\Model\Session')
             ->getQuote()
             ->load($quoteId);
 
echo '<pre>';
print_r($quote->getOrigData());
echo '</pre>';
 
$productId = 1;
$product = $obj->get('Magento\Catalog\Model\ProductRepository')
               ->getById($productId);
 
echo '<pre>';
print_r($product->getData());
echo '</pre>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment