PHP code example of smalot / magento-bundle

1. Go to this page and download the library: Download smalot/magento-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

smalot / magento-bundle example snippets


# app/AppKernel.php

# ...

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            # ...
            new Smalot\MagentoBundle\MagentoBundle(),
        );

        return $bundles;
    }
}

class MagentoController extends Controller
{
    /**
     * @Route("/", name="magento_index")
     */
    public function indexAction(Request $request)
    {
        // Retrieve default connection.
        $magento = $this->get('magento')->getManager();

        if ($magento->ping()) {
            // Call any module's class.
            $categoryManager = new \Smalot\Magento\Catalog\Category($magento);
            $tree            = $categoryManager->getTree()->execute();
        } else {
            $tree = array();
        }

        $magento->logout();

        return new Response('<html><body><pre>' . var_export($tree, true) . '</pre></body></html>');
    }
}

$magento = $this->get('magento')->getManager('second_connection_name');