$ composer require bitbag/inpost-plugin
Add plugin dependencies to your config/bundles.php
file:
return [
...
BitBag\SyliusInPostPlugin\BitBagSyliusInPostPlugin::class => ['all' => true]
];
Import required config in your config/packages/_sylius.yaml
file:
# config/packages/_sylius.yaml
imports:
...
- { resource: "@BitBagSyliusInPostPlugin/Resources/config/config.yml" }
Import routing in your config/routes.yaml
file:
# config/routes.yaml
...
bitbag_sylius_inpost_plugin:
resource: "@BitBagSyliusInPostPlugin/Resources/config/routes.yml"
This plugin was made on top of SyliusShippingExportPlugin, so please remember to do the same for it's configuration.
Add trait and interface to your Order and ShippingMethod entity classes:
<?php
declare(strict_types=1);
namespace App\Entity\Order;
use BitBag\SyliusInPostPlugin\Model\InPostPointsAwareInterface;
use Sylius\Component\Core\Model\Order as BaseOrder;
use BitBag\SyliusInPostPlugin\Model\OrderPointTrait;
class Order extends BaseOrder implements InPostPointsAwareInterface
{
use OrderPointTrait;
}
<?php
declare(strict_types=1);
namespace App\Entity\Shipping;
use BitBag\SyliusInPostPlugin\Model\ShippingMethodImageTrait;
use Sylius\Component\Core\Model\ImageAwareInterface;
use Sylius\Component\Core\Model\ShippingMethod as BaseShippingMethod;
class ShippingMethod extends BaseShippingMethod implements ImageAwareInterface
{
use ShippingMethodImageTrait;
}
Define new Entity mapping inside your src/Resources/config/doctrine directory. (You can do it with annotations if you prefer)
<?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="Tests\BitBag\SyliusInPostPlugin\Application\src\Entity\Order" table="sylius_order">
<one-to-one field="point" target-entity="BitBag\SyliusInPostPlugin\Entity\InPostPoint">
<cascade>
<cascade-persist/>
<cascade-remove/>
<cascade-refresh/>
</cascade>
<join-column name="point_id" referenced-column-name="id" nullable="true"/>
</one-to-one>
</entity>
</doctrine-mapping>
<?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="Tests\BitBag\SyliusInPostPlugin\Application\src\Entity\ShippingMethodImage" table="bitbag_inpost_shipping_method_image">
<one-to-one field="owner" target-entity="Sylius\Component\Shipping\Model\ShippingMethodInterface" inversed-by="image">
<join-column name="owner_id" referenced-column-name="id" nullable="false" on-delete="CASCADE"/>
</one-to-one>
</entity>
</doctrine-mapping>
Finish the installation by updating the database schema:
$ bin/console doctrine:migrations:diff
$ bin/console doctrine:migrations:migrate
$ bin/console assets:install --symlink
$ bin/console sylius:theme:assets:install --symlink
$ composer install
$ cd tests/Application
$ yarn install
$ yarn encore dev
$ bin/console assets:install public -e test
$ bin/console doctrine:database:create -e test
$ bin/console doctrine:schema:create -e test
$ bin/console server:run 127.0.0.1:8080 -d public -e test
$ open http://localhost:8080
$ vendor/bin/behat
$ vendor/bin/phpspec run