I need to pull product data out of Magento 2 via an external PHP command line script.
I am using the example here: How can I bootstrap Magento 2 in a test.php script?
In the run method, I extract my product collection and parse my product data into a new array without any problem.
public function run()
{
// create collection
// parse collection
// build $_products data array
return ['data' => $_products];
}
If I dump or echo $_products
out in run()
I can see the product data ok, I need to return the product data to the calling function but cannot see how to retrieve the data. I am initiating my app with
$app = $bootstrap->createApplication('Getapp');
$bootstrap->run($app);
How can I access the data returned from Getapp and how can I pass variables into Getapp?