setono / sylius-items-sold-plugin
Sylius Plugin to display items sold on every Product/ProductVariant details admin page.
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 1
Type:sylius-plugin
Requires
- php: ^7.1
- sylius/sylius: ~1.2.3
- symfony/symfony: ^3.4|^4.1
Requires (Dev)
- behat/behat: ^3.4
- behat/mink: ^1.7@dev
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2.2
- behat/mink-selenium2-driver: ^1.3
- friends-of-behat/context-service-extension: ^1.2
- friends-of-behat/cross-container-extension: ^1.1
- friends-of-behat/service-container-extension: ^1.0
- friends-of-behat/symfony-extension: ^1.2.1
- friends-of-behat/variadic-extension: ^1.1
- lakion/mink-debug-extension: ^1.2.3
- phpspec/phpspec: ^4.0
- phpstan/phpstan-doctrine: ^0.10
- phpstan/phpstan-shim: ^0.10
- phpstan/phpstan-symfony: ^0.10
- phpstan/phpstan-webmozart-assert: ^0.10
- phpunit/phpunit: ^6.5
- sylius-labs/coding-standard: ^2.0
This package is auto-updated.
Last update: 2024-12-15 04:20:34 UTC
README
Sylius Plugin to display items sold on every Product/ProductVariant details admin page
Install
Add plugin to composer.json
composer require setono/sylius-items-sold-plugin
Register plugin at AppKernel.php
# app/AppKernel.php final class AppKernel extends Kernel { public function registerBundles(): array { return array_merge(parent::registerBundles(), [ // ... new \Setono\SyliusItemsSoldPlugin\SetonoSyliusItemsSoldPlugin(), ]); } }
Add routing
# app/config/routing.yml setono_sylius_items_sold_plugin_admin: resource: "@SetonoSyliusItemsSoldPlugin/Resources/config/admin_routing.yml" prefix: /admin
Configure plugin (optional)
You can omit this step as far as plugin works even without configuration. In that case result will count carts/orders in any (checkout/payment/shipment) states without any interval limitation and will not be cached.
But lets suppose we need to:
- See how much times every item was sold last 14 days
- Cache that values for 30 mins (1800 seconds) to decrease server load a bit
- We don't want to count orders in states other than in payed and shipped
# app/config/config.yml services: app.setono_sylius_items_sold.cache: class: Symfony\Component\Cache\Simple\FilesystemCache arguments: - '' - 0 - "%kernel.cache_dir%/items-sold" setono_sylius_items_sold: cache: service: 'app.setono_sylius_items_sold.cache' ttl: 1800 interval: 14 payment_states: - paid shipping_states: - shipped
Tips:
- Don't forget to clean cache after changing
interval
parameter. - Don't specify
interval
if you wish to count even items added to carts (as far as cart doesn't have order date atcheckoutCompletedAt
field) - Discover
Setono\SyliusItemsSoldPlugin\DependencyInjection\Configuration
for more info about config options
(Manually) Test plugin
-
Run application: (by default application have default config at
dev
environment and example config fromConfigure plugin
step atprod
environment)SYMFONY_ENV=dev cd tests/Application && \ yarn install && \ yarn run gulp && \ bin/console assets:install web -e $SYMFONY_ENV && \ bin/console doctrine:database:create -e $SYMFONY_ENV && \ bin/console doctrine:schema:create -e $SYMFONY_ENV && \ bin/console sylius:fixtures:load -e $SYMFONY_ENV && \ bin/console server:run -d web -e $SYMFONY_ENV
-
Log in at
http://localhost:8000/admin
with Sylius demo credentials:Login: sylius@example.com Password: sylius
-
Go to any product edit page like
http://localhost:8000/admin/products/1
-
Or to product variant page like
http://localhost:8000/admin/products/1/variants/1/edit
-
See how much that item was ordered (or even added to cart depending on config)