-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the grid in the extension instead of a custom config.yaml file
- Loading branch information
Showing
5 changed files
with
142 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,80 @@ | ||
# Setono Sylius Plugin Skeleton | ||
# Sylius Catalog Promotion Plugin | ||
|
||
[![Latest Version][ico-version]][link-packagist] | ||
[![Latest Unstable Version][ico-unstable-version]][link-packagist] | ||
[![Software License][ico-license]](LICENSE) | ||
[![Build Status][ico-github-actions]][link-github-actions] | ||
[![Code Coverage][ico-code-coverage]][link-code-coverage] | ||
[![Mutation testing][ico-infection]][link-infection] | ||
|
||
[Setono](https://setono.com) have made a bunch of [plugins for Sylius](https://github.com/Setono?q=plugin&sort=stargazers), and we have some guidelines | ||
which we try to follow when developing plugins. These guidelines are used in this repository, and it gives you a very | ||
solid base when developing plugins. | ||
|
||
Enjoy! | ||
|
||
## Quickstart | ||
|
||
1. Run | ||
```shell | ||
composer create-project --prefer-source --no-install --remove-vcs setono/sylius-plugin-skeleton:1.12.x-dev ProjectName | ||
``` | ||
or just click the `Use this template` button at the right corner of this repository. | ||
2. Run | ||
```shell | ||
cd ProjectName && composer install | ||
``` | ||
3. From the plugin skeleton root directory, run the following commands: | ||
|
||
```bash | ||
php init | ||
(cd tests/Application && yarn install) | ||
(cd tests/Application && yarn build) | ||
(cd tests/Application && bin/console assets:install) | ||
(cd tests/Application && bin/console doctrine:database:create) | ||
(cd tests/Application && bin/console doctrine:schema:create) | ||
(cd tests/Application && bin/console sylius:fixtures:load -n) | ||
``` | ||
|
||
4. Start your local PHP server: `symfony serve` (see https://symfony.com/doc/current/setup/symfony_server.html for docs) | ||
|
||
To be able to set up a plugin's database, remember to configure you database credentials in `tests/Application/.env` and `tests/Application/.env.test`. | ||
[ico-version]: https://poser.pugx.org/setono/sylius-plugin-skeleton/v/stable | ||
[ico-license]: https://poser.pugx.org/setono/sylius-plugin-skeleton/license | ||
[ico-github-actions]: https://github.com/Setono/SyliusPluginSkeleton/workflows/build/badge.svg | ||
[ico-code-coverage]: https://codecov.io/gh/Setono/SyliusPluginSkeleton/branch/1.12.x/graph/badge.svg | ||
[ico-infection]: https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2FSetono%2FSyliusPluginSkeleton%2F1.12.x | ||
[link-packagist]: https://packagist.org/packages/setono/sylius-plugin-skeleton | ||
[link-github-actions]: https://github.com/Setono/SyliusPluginSkeleton/actions | ||
[link-code-coverage]: https://codecov.io/gh/Setono/SyliusPluginSkeleton | ||
[link-infection]: https://dashboard.stryker-mutator.io/reports/github.com/Setono/SyliusPluginSkeleton/1.12.x | ||
|
||
Plugin for Sylius to define permanent or time-limited promotions for products and automatically update prices. | ||
|
||
![Screenshot showing catalog promotions admin page](docs/admin-create.png) | ||
|
||
## Install | ||
|
||
### Add plugin to composer.json | ||
|
||
```bash | ||
composer require setono/sylius-catalog-promotion-plugin | ||
``` | ||
|
||
### Register plugin | ||
|
||
```php | ||
<?php | ||
# config/bundles.php | ||
|
||
return [ | ||
// ... | ||
Setono\SyliusCatalogPromotionPlugin\SetonoSyliusCatalogPromotionPlugin::class => ['all' => true], | ||
Sylius\Bundle\GridBundle\SyliusGridBundle::class => ['all' => true], | ||
// ... | ||
]; | ||
|
||
``` | ||
|
||
**Note**, that we MUST define `SetonoSyliusCatalogPromotionPlugin` BEFORE `SyliusGridBundle`. | ||
Otherwise, you'll see exception like this: | ||
|
||
```bash | ||
You have requested a non-existent parameter "setono_sylius_catalog_promotion.model.promotion.class". | ||
``` | ||
|
||
### Add routing | ||
|
||
```yaml | ||
# config/routes/setono_sylius_catalog_promotion.yaml | ||
setono_sylius_catalog_promotion_admin: | ||
resource: "@SetonoSyliusCatalogPromotionPlugin/Resources/config/admin_routing.yaml" | ||
prefix: /admin | ||
``` | ||
### Extend core classes | ||
TODO: Extend `Product` class | ||
|
||
### Create migration | ||
|
||
```bash | ||
php bin/console doctrine:migrations:diff | ||
php bin/console doctrine:migrations:migrate | ||
``` | ||
|
||
### Install assets | ||
|
||
```bash | ||
bin/console sylius:install:assets | ||
``` | ||
|
||
### Configure cron (optional) | ||
|
||
```bash | ||
php bin/console setono:sylius-catalog-promotion:process | ||
``` | ||
|
||
[ico-version]: https://poser.pugx.org/setono/sylius-catalog-promotion-plugin/v/stable | ||
[ico-unstable-version]: https://poser.pugx.org/setono/sylius-catalog-promotion-plugin/v/unstable | ||
[ico-license]: https://poser.pugx.org/setono/sylius-catalog-promotion-plugin/license | ||
[ico-github-actions]: https://github.com/Setono/SyliusCatalogPromotionPlugin/workflows/build/badge.svg | ||
|
||
[link-packagist]: https://packagist.org/packages/setono/sylius-catalog-promotion-plugin | ||
[link-github-actions]: https://github.com/Setono/SyliusCatalogPromotionPlugin/actions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
tests/Application/config/packages/setono_sylius_catalog_promotion.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
imports: | ||
- { resource: "@SetonoSyliusCatalogPromotionPlugin/Resources/config/app/config.yaml" } | ||
- { resource: "@SetonoSyliusCatalogPromotionPlugin/Resources/config/app/fixtures.yaml" } |