We want to impact many unique eCommerce projects and build our brand recognition worldwide, so we are heavily involved in creating open-source solutions, especially for Sylius. We have already created over 35 extensions, which have been downloaded almost 2 million times.
You can find more information about our eCommerce services and technologies on our website: https://bitbag.io/. We have also created a unique service dedicated to creating plugins: https://bitbag.io/services/sylius-plugin-development.
Do you like our work? Would you like to join us? Check out the “Career” tab: https://bitbag.io/pl/kariera.
BitBag is a software house that implements tailor-made eCommerce platforms with the entire infrastructure—from creating eCommerce platforms to implementing PIM and CMS systems to developing custom eCommerce applications, specialist B2B solutions, and migrations from other platforms.
We actively participate in Sylius's development. We have already completed over 150 projects, cooperating with clients worldwide, including smaller enterprises and large international companies. We have completed projects for such important brands as Mytheresa, Foodspring, Planeta Huerto (Carrefour Group), Albeco, Mollie, and ArtNight.
We have a 70-person team of experts: business analysts and consultants, eCommerce developers, project managers, and QA testers.
Our services:
- B2B and B2C eCommerce platform implementations
- Multi-vendor marketplace platform implementations
- eCommerce migrations
- Sylius plugin development
- Sylius consulting
- Project maintenance and long-term support
- PIM and CMS implementations
Some numbers from BitBag regarding Sylius:
- 70 experts on board
- +150 projects delivered on top of Sylius
- 30 countries of BitBag’s customers
- 7 years in the Sylius ecosystem
- +35 plugins created for Sylius
- Overview
- Screenshots
- Installation
- Demo
- Additional resources for developers
- License
- Contact and support
The callout plugin for Sylius allows you to configure nice badges for different set of products based on specific rules. It provides a common set of configuration by default and is very flexible when it comes to adding new ones.
Supports Doctrine ORM driver only.
Shop:
Admin:
This plugin depends upon the Doctrine ORM Batcher bundle. Install that bundle first.
Open a command console, enter your project directory and execute the following command to download the latest stable version of this plugin:
$ composer require setono/sylius-callout-plugin
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the plugin by adding it to the list of registered plugins/bundles
in config/bundles.php
file of your project before (!) SyliusGridBundle
:
<?php
$bundles = [
Setono\DoctrineORMBatcherBundle\SetonoDoctrineORMBatcherBundle::class => ['all' => true],
Setono\SyliusCalloutPlugin\SetonoSyliusCalloutPlugin::class => ['all' => true],
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true],
];
Don't forget to add SetonoDoctrineORMBatcherBundle
as this plugin require bundle to be enabled.
# config/packages/setono_product_callout.yaml
imports:
- { resource: "@SetonoSyliusCalloutPlugin/Resources/config/app/config.yaml" }
setono_sylius_callout:
manual_triggering: false
# Enable manual triggering if your store have too much products
# That way you can trigger callouts assign process manually when
# finish adding all rules
# manual_triggering: true
no_rules_eligible: false
# Set this option to true if you want no rules to be
# treated as eligible (e.g. callout without rules will
# be applied to all products)
# no_rules_eligible: true
# config/routes/setono_product_callout.yaml
setono_product_callout:
resource: "@SetonoSyliusCalloutPlugin/Resources/config/routing.yaml"
Read more about Sylius models customization here.
Add a Setono\SyliusCalloutPlugin\Model\CalloutsAwareTrait
trait to your App\Entity\Product
class.
-
If you use
annotations
mapping:<?php // src/Entity/Product.php namespace App\Entity; use Setono\SyliusCalloutPlugin\Model\CalloutsAwareTrait as SetonoSyliusCalloutCalloutsAwareTrait; use Setono\SyliusCalloutPlugin\Model\ProductInterface as SetonoSyliusCalloutProductInterface; use Sylius\Component\Core\Model\Product as BaseProduct; use Doctrine\ORM\Mapping as ORM; /** * @ORM\Entity * @ORM\Table(name="sylius_product") */ class Product extends BaseProduct implements SetonoSyliusCalloutProductInterface { use SetonoSyliusCalloutCalloutsAwareTrait { SetonoSyliusCalloutCalloutsAwareTrait::__construct as private __calloutsTraitConstruct; } public function __construct() { $this->__calloutsTraitConstruct(); parent::__construct(); } }
-
If you use
xml
mapping:<?php // src/Model/Product.php namespace App\Model; use Setono\SyliusCalloutPlugin\Model\CalloutsAwareTrait as SetonoSyliusCalloutCalloutsAwareTrait; use Setono\SyliusCalloutPlugin\Model\ProductInterface as SetonoSyliusCalloutProductInterface; use Sylius\Component\Core\Model\Product as BaseProduct; class Product extends BaseProduct implements SetonoSyliusCalloutProductInterface { use SetonoSyliusCalloutCalloutsAwareTrait { SetonoSyliusCalloutCalloutsAwareTrait::__construct as private __calloutsTraitConstruct; } public function __construct() { $this->__calloutsTraitConstruct(); parent::__construct(); } }
<?xml version="1.0" encoding="UTF-8"?> <doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> <entity name="App\Model\Product" table="sylius_product"> <many-to-many field="callouts" target-entity="Setono\SyliusCalloutPlugin\Model\CalloutInterface"> <join-table name="setono_sylius_callout__product_callouts"> <join-columns> <join-column name="product_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" /> </join-columns> <inverse-join-columns> <join-column name="callout_id" referenced-column-name="id" nullable="false" on-delete="CASCADE" /> </inverse-join-columns> </join-table> </many-to-many> </entity> </doctrine-mapping>
If you haven't done so already, configure the sylius_product
resource to point to your App\Entity\Product
like we
did in an example here.
$ php bin/console doctrine:migrations:diff
$ php bin/console doctrine:migrations:migrate
Add callouts to your product box template. By default, you should use templates/bundles/SyliusShopBundle/Product/_box.html.twig
path. Check out our _box.html.twig file for a reference.
Note the line: {% include "@SetonoSyliusCalloutPlugin/Shop/Product/Callout/_callouts.html.twig" with {'callouts' : product.callouts|setono_callouts} %}
.
All commands in this plugin will extend the CommandInterface. Therefore you can route all commands easily by adding this to your Messenger config:
# config/packages/messenger.yaml
framework:
messenger:
routing:
# Route all command messages to the async transport
# This presumes that you have already set up an 'async' transport
'Setono\SyliusCalloutPlugin\Message\Command\CommandInterface': async
For the performance reasons, configure a cron job on your production server to execute $ bin/console setono:sylius-callout:assign
command
once in a while in order to rebuild the index for callouts. In most cases it should be done by the resource event listener
triggered anytime you create/update a product or callout, but it is worth to have it covered if something goes wrong.
Example cron configuration (EDITOR=nano sudo crontab -e
) to run command once a day:
0 2 * * * www-data /var/www/html/bin/console setono:sylius-callout:assign --env=prod
$ bin/console assets:install
From now on you should be able to add new callouts in the admin panel. Once you add one, you just need to configure.
- Configure a new form under
App\Form\Type\Rule
namespace, - Add a rule checker under
App\Checker\Rule
namespace and make sure it implementsSetono\SyliusCalloutPlugin\Callout\Checker\Rule\ProductCalloutRuleCheckerInterface
interface and has apublic const TYPE
set corresponding to the below service configuration - Register and tag new services:
<!-- services.xml -->
<services>
...
<service id="app.callout_rule_checker.is_on_sale" class="Setono\SyliusCalloutPlugin\Callout\Checker\Rule\IsOnSaleRuleChecker">
<argument type="service" id="setono_sylius_callout.checker.product_promotion" />
<tag name="setono_sylius_callout.callout_rule_checker" type="is_on_sale" label="setono_sylius_callout.ui.is_on_sale" form-type="Setono\SyliusCalloutPlugin\Form\Type\Rule\IsOnSaleConfigurationType" />
</service>
<service id="app.form.type.rule.is_on_sale" class="Setono\SyliusCalloutPlugin\Form\Type\Rule\IsOnSaleConfigurationType">
<tag name="form.type" />
</service>
</services>
-
The service "setono_sylius_callout.command_bus.middleware.handle_message" has a dependency on a non-existent service "setono_doctrine_orm_batcher.factory.batcher".
You forgot to add
SetonoDoctrineORMBatcherBundle
to your app'sbundles.php
We created a demo app with some useful use-cases of plugins! Visit sylius-demo.bitbag.io to take a look at it. The admin can be accessed under sylius-demo.bitbag.io/admin/login link and bitbag: bitbag credentials.
To learn more about our contribution workflow and more, we encourage you to use the following resources:
This plugin's source code is completely free and released under the terms of the MIT license.
This open-source plugin was developed to help the Sylius community. If you have any additional questions, would like help with installing or configuring the plugin, or need any assistance with your Sylius project - let us know! Contact us or send us an e-mail to [email protected] with your question(s).
For online communication, we invite you to chat with us & other users on Sylius Slack.