Developed with love by KnpLabs Hire us for your project!
20

SuluProductBundle

by sulu

Sulu product bundle

SuluProductBundle Build Status StyleCI

Dependencies

Sulu:

This version of product-bundle will only work with sulu version >= 1.3.
If you use an older sulu version please use product-bundle version
~0.16.

Installation

Add the following to composer.json

"sulu/product-bundle": "~0.16"

Add the following to your application kernel:

// Product bundle
new Sulu\Bundle\ProductBundle\SuluProductBundle(),
new Sulu\Bundle\ValidationBundle\SuluValidationBundle(),

Add the following to your admin/routing.yml:

# Sulu Product Bundle
sulu_product:
    resource: "@SuluProductBundle/Resources/config/routing.yml"
    prefix: /admin/product

sulu_product_api:
    type: rest
    resource: "@SuluProductBundle/Resources/config/routing_api.yml"
    prefix: /admin/api

Configuration

Sample configuration:

sulu_route:
    mappings:
        Sulu\Bundle\ProductBundle\Entity\ProductTranslation:
            generator: schema
            options:
                route_schema: /products/{object.getName()}

sulu_product:
    category_root_key: ~
    default_currency: 'EUR'
    default_formatter_locale: 'en'
    display_recurring_prices: true
    fallback_locale: de
    fixtures:
        attributes:
            - src/Acme/Bundle/ProductBundle/DataFixtures/attributes.xml
    locales:
        - de
        - en
    objects:
        product:
            model: Acme\Bundle\ProductBundle\Entity\Product
            repository: Acme\Bundle\ProductBundle\Entity\ProductRepository
    template: AcmeShopBundle:views:templates/productdetail.html.twig

Note: If you use Sulu 1.3.* routing has to be defined as follows:

sulu_route:
    mappings:
        Sulu\Bundle\ProductBundle\Entity\ProductTranslation:
            route_schema: /products/{object.getName()}

Localization

Multiple locales for managing products can be defined in the config.
If non defined, 'en' is taken as default.

If the users language matches any of the given locales, that one is
displayed in the admin area. Otherwise the fallback_locale parameter
is used.

Custom Routing

You can define custom routes by defining the sulu_route.mappings
parameter for ProductTranslation entity.
Then you can specify the sulu_product.template parameter to define
which template is shown when route is called.

To update routes for existing products, simply call

var/console sulu:route:update SuluProductBundle:ProductTranslation --batch-size 1

How the routing mechanism works

When creating a new product translation a new route is created.
You then can change the route's path in the content tab.

The following properties are available when defining a route:

  • object (ProductTranslation)
  • product (Api/Product) and of course
  • translator

Recurring prices

The property recurring prices can be disabled via parameter
display_recurring_prices. This option hides the UI elements for
recurring prices.

Custom Entity and Repository

If you'd like to overwrite the sulu product entity you simply need to
set the objects.product parameters.

Shop templates

For shop purposes template can be used to define the template for
displaying product details.

Attribute Fixtures

You can write multiple attribute fixture files and define the path of
your xmls in your config (as seen in the example above)

Example XML

<attributes>
    <attribute>
        <key>example.key</key>
        <type>1</type>
        <names>
            <name locale="en">English Attribute</name>
            <name locale="de">German Attribute</name>
        </names>
        <values>
            <value>
                <name locale="de">German Value 1</name>
                <name locale="en">English Value 1</name>
            </value>
            <value>
                <name locale="de">German Value 2</name>
                <name locale="en">English Value 2</name>
            </value>
        </values>
    </attribute>
</attributes>

Content type 'product'

<property name="product" type="product" mandatory="true">
    <meta>
        <title lang="de">Produkt</title>
        <title lang="en">Product</title>
    </meta>
</property>

API Documentation

The following api's have been documented:
Product Addon Api
Product Variant Api

Developer Documentation

The sulu product developer documentation can be found here:
Developer Documentation

Copyright (c) MassiveArt Webservices GmbH

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
sulu_product:
category_root_key: ~
default_currency: EUR
default_formatter_locale: en
display_recurring_prices: true
fallback_locale: en
fixtures:
attributes: []
locales:

# Defaults:
- de
- en
template: SuluProductBundle:WebsiteProduct:product-detail.html.twig
objects:
product:
model: Sulu\Bundle\ProductBundle\Entity\Product
repository: Sulu\Bundle\ProductBundle\Entity\ProductRepository
types:
product:
template: SuluProductBundle:Template:content-types/product-selection.html.twig
  • Merge pull request #374 from sulu/bugfix/content-type-remove
    By web-flow, 6 months ago
  • Fixed removing of products in the content type
    By , 6 months ago
  • Update CHANGELOG.md
    By web-flow, 7 months ago
  • Merge pull request #372 from sulu/bugfix/autocomplete-double-results
    By web-flow, 7 months ago
  • added changes
    By , 7 months ago
  • removed prefatch url from autocomplete options
    By wynny, 7 months ago
  • Merge pull request #370 from sulu/feature/sulu-1.6
    By web-flow, 8 months ago
  • Fixed changelog
    By sabinebaer, 8 months ago
  • Readded willdurand/hateoas-bundle
    By sabinebaer, 8 months ago
  • Removed willdurand/hateoas-bundle
    By sabinebaer, 8 months ago
  • prepare relaease
    By wynny, 10 months ago
  • Merge pull request #369 from sulu/feature/attributes-selection-field
    By web-flow, 10 months ago
  • compiled
    By wynny, 10 months ago
  • fix after review
    By wynny, 10 months ago
  • added changes
    By wynny, 10 months ago
  • fix javascript to save attribute
    By wynny, 10 months ago
  • fixed autocomplete js, set limit
    By wynny, 10 months ago
  • changed attributes field from dropdown to autocomplete
    By notsure, 10 months ago
  • Merge branch 'master' of https://github.com/sulu/SuluProductBundle into develop
    By mob8607, 11 months ago
  • updated changelog
    By mob8607, 11 months ago
  • Merge branch 'master' of https://github.com/sulu/SuluProductBundle into develop
    By mob8607, 11 months ago
  • Merge branch 'release/0.16' of https://github.com/sulu/SuluProductBundle
    By mob8607, 11 months ago
  • fixed a bug in the addon overlay if price is overwritten with 0 (#368)
    By web-flow, 11 months ago
  • Fix type in default_formatter_locale (#367)
    By wachterjohannes, 1 year ago
  • Merge pull request #365 from sulu/bugfix/variant-overlay
    By web-flow, 1 year ago
  • Fixed various bugs in variants overlay
    By turbo-ele, 1 year ago
  • Merge pull request #366 from sulu/bugfix/variant-overlay
    By web-flow, 1 year ago
  • Fixed various bugs in variants overlay
    By turbo-ele, 1 year ago
  • Prepared for release
    By turbo-ele, 1 year ago
  • Merge pull request #362 from sulu/bugfix/style-ci
    By web-flow, 1 year ago