Coder Social home page Coder Social logo

magento-bundle's Introduction

MagentoBundle

This project is a bridge between Symfony 2 and Magento-Client API which allow to call easily the Magento Soap v1 API.

Scrutinizer Code Quality Total Downloads Current Version License

Allows :

  • wrappers for each call
  • dependencies injections
  • event listeners
  • debug toolbar integration
  • and ... code completion

Requirements

  • Symfony >= 2.1
  • PHP >= 5.3
  • smalot/magento-client

Installation

Add the following lines to your composer.json:

{
    "require": {
        "smalot/magento-bundle": "*"
    }
}

And run php composer.phar update smalot/magento-bundle

Then, register the bundle in your kernel:

# app/AppKernel.php

# ...

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

        return $bundles;
    }
}

Configuration

You need to setup at least one connection in the connections pool and specify it with the default_connection property. The mandatory properties are: url, api_user and api_key.

# app/config/config.yml

# Sample configuration
magento:
    # Refers to the default connection in the connection pool
    default_connection:   default # Example: default

    # List all available connections
    connections:

        # Prototype
        default:
            url:                  http://domain.tld/magento/
            api_user:             username
            api_key:              0123456789AZ

            # Enable logging system
            logging:              %kernel.debug%

            # Refers to the logger service
            logger:               ~

            # Refers to the dispatcher service
            dispatcher:           ~

Details

Service(s) provided:

  • magento

Events thrown in security context:

  • \Smalot\MagentoBundle\MagentoEvents::PRE_LOGIN
  • \Smalot\MagentoBundle\MagentoEvents::POST_LOGIN
  • \Smalot\MagentoBundle\MagentoEvents::PRE_LOGOUT
  • \Smalot\MagentoBundle\MagentoEvents::POST_LOGOUT

Events thrown in transport context:

  • \Smalot\MagentoBundle\MagentoEvents::PRE_SINGLE_CALL
  • \Smalot\MagentoBundle\MagentoEvents::POST_SINGLE_CALL
  • \Smalot\MagentoBundle\MagentoEvents::PRE_MULTI_CALL
  • \Smalot\MagentoBundle\MagentoEvents::POST_MULTI_CALL

Sample codes

Using the default connection:

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>');
    }
}

The connection can be specified manually if needed:

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.