ecommerce-archive / EcommerceCoreBundle

3 stars 0 forks source link

Ecommerce Core Bundle

Question? Bug? Feature request? Feedback? Please don’t hesitate to open an issue - I will get back to you asap!

Introduction

This bundle is a base to build a Symfony2 ecommerce application. It focuses on solutions with a high degree of customization. It’s a toolset to implement your own business and application logic. If you’re looking for a 'out of the box' webshop you should rather choose a different solution like Sylius or Vespolina. It takes care of persistence and you can optionally use the RESTful controllers for the products and the cart. You write your own product handler (or several ones if your project requires it) which defines the product properties (as many as you want and translatable without having to update the database thanks to PHPCR), product options, cart item validation and product availability. You can hook into all different kinds of events to adapt the provided application flow to your needs.

Status

! Work in progress - Not Ready for Production Use !

It currently doesn’t provide a default product handler so you have to write your own. I haven’t decided yet whether to provide a default one or just create a tutorial for that (just look at the ecommerce-sandbox for now). For simplicity reasons it currently contains features which are not needed by everyone (like e.g. translatable product properties, a REST controller). They will be extracted to seperate libraries or bundles in the future.

The first webshop based on this bundle is ready to launch. The shop allows users to rent different kinds of products (using a custom availability check for a product in different sizes and a different rental durations) and buy other items.

Services and classes

Service id Class
ecommerce_core.cart.controller Ecommerce\Bundle\CoreBundle\Controller\CartController
ecommerce_core.product.controller Ecommerce\Bundle\CoreBundle\Controller\ProductController
ecommerce_core.cart.manager Ecommerce\Bundle\CoreBundle\Cart\Manager
ecommerce_core.cart.repository Ecommerce\Bundle\CoreBundle\Doctrine\Orm\CartRepository
ecommerce_core.cart_item.repository Ecommerce\Bundle\CoreBundle\Doctrine\Orm\CartItemRepository
ecommerce_core.event_listener.doctrine_orm_subscriber Ecommerce\Bundle\CoreBundle\EventListener\DoctrineOrmSubscriber
ecommerce_core.event_listener.doctrine_phpcr_subscriber Ecommerce\Bundle\CoreBundle\EventListener\DoctrinePhpcrSubscriber
ecommerce_core.product.form.type.translated_property Ecommerce\Bundle\CoreBundle\Product\Form\Type\TranslatedPropertyType
ecommerce_core.product.handler_manager Ecommerce\Bundle\CoreBundle\Product\HandlerManager
ecommerce_core.product.manager Ecommerce\Bundle\CoreBundle\Product\Manager
ecommerce_core.product.repository Ecommerce\Bundle\CoreBundle\Doctrine\Phpcr\ProductRepository
ecommerce_core.product_reference.repository Ecommerce\Bundle\CoreBundle\Doctrine\Orm\ProductReferenceRepository
ecommerce_core.twig.ecommerce_extension Ecommerce\Bundle\CoreBundle\Twig\EcommerceExtension
ecommerce_core.controller_utils Ecommerce\Bundle\CoreBundle\Util\ControllerUtils

Use the tag ecommmerce.product_handler to register your product handler.

Products (Ecommerce\Bundle\CoreBundle\Doctrine\Phpcr\Product) are stored in PHPCR but a simple ProductReference (Ecommerce\Bundle\CoreBundle\Doctrine\Orm\ProductReference) entity is stored in ORM so it can be associated with a CartItem (Ecommerce\Bundle\CoreBundle\Doctrine\Orm\CartItem). The Cart (Ecommerce\Bundle\CoreBundle\Doctrine\Orm\CartItem) entity is very basic for now but will be updated soon to include subtotals, discounts, tax information etc.

To create a form type for a product use the Ecommerce\Bundle\CoreBundle\Product\Form\DataMapper\ProductDataMapper as the DataMapper ($builder->setDataMapper(new ProductDataMapper()); in the buildForm method) and the ecommerce_type_translated_property form type for product properties that should be translatable. Those properties can then be rendered using the twig function translate_property(product, property).

Installation

php composer.phar require ecommerce/core-bundle:dev-master

Add the following lines to app/AppKernel.php (assuming your project already includes the bundles from Symfony Framework Standard Edition):

            new Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle(),
            new Ecommerce\Bundle\CoreBundle\EcommerceCoreBundle(),

Add

AnnotationRegistry::registerFile(__DIR__.'/../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Mapping/Annotations/DoctrineAnnotations.php');

before return $loader; in app/autoload.php.

Update the database by running (not recommended for production):

php app/console doctrine:phpcr:init:dbal
php app/console doctrine:phpcr:workspace:create default
php app/console doctrine:phpcr:repository:init
php app/console doctrine:schema:update --force

You can check out the ecommerce-sandbox to see how it should look like.

Next

Feel free to open an issue for any feature request!

License

This bundle is under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE

Please note that it requires other libraries to run (see Packagist) and not all of them are MIT-licensed (like Apache 2.0).