Skip to content

Commit

Permalink
Merge pull request #21 from BitBagCommerce/OP-521
Browse files Browse the repository at this point in the history
OP-521 - installation.md - new standard
  • Loading branch information
senghe authored Sep 9, 2024
2 parents d3e3e29 + 7ae8905 commit 2de4cb7
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 154 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
run: vendor/bin/behat --colors --strict -vvv --no-interaction || vendor/bin/behat --colors --strict -vvv --no-interaction --rerun

- name: Upload Behat logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
if: failure()
with:
name: Behat logs
Expand Down
165 changes: 12 additions & 153 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,164 +38,23 @@ In some e-commerce cases there is a need for grouping product attributes togethe

## Installation

----

1. *We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.*

```bash
composer require bitbag/product-attribute-groups-plugin --no-scripts
```

2. Add plugin dependencies to your `config/bundles.php` file:

```php
return [
...

BitBag\SyliusProductAttributeGroupsPlugin\BitBagSyliusProductAttributeGroupsPlugin::class => ['all' => true],
];
```

3. Import required config in your `config/packages/_sylius.yaml` file:

```yaml
# config/packages/_sylius.yaml

imports:
...

- { resource: "@BitBagSyliusProductAttributeGroupsPlugin/Resources/config/config.yml" }
```
4. Add required routes:
```yaml
# config/routes.yaml
...

bitbag_product_attribute_groups_plugin:
resource: "@BitBagSyliusProductAttributeGroupsPlugin/Resources/config/routing.yml"
```
5. Please clear the cache:
```bash
bin/console cache:clear
```

6. Please update your database by running:

```bash
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate # Please review the file and changes before running the command!
```

Or by using schema tool:

```bash
bin/console doctrine:schema:update --dump-sql # Please use --force switch when you're done which checking the db changes.
```

7. Import plugin's `webpack.config.js` file

```js
// webpack.config.js
const [ bitbagProductAttributeGroupsAdmin ] = require('./vendor/bitbag/product-attribute-groups-plugin/webpack.config.js')
...

module.exports = [..., bitbagProductAttributeGroupsAdmin];
```

8. Add new packages in `./config/packages/assets.yaml`

```yml
# config/packages/assets.yaml

framework:
assets:
packages:
# ...
product_attribute_groups_admin:
json_manifest_path: '%kernel.project_dir%/public/build/bitbag/productAttributeGroups/admin/manifest.json'
```
9. Add new build paths in `./config/packages/webpack_encore.yml`

```yml
# config/packages/webpack_encore.yml
webpack_encore:
builds:
# ...
product_attribute_groups_admin: '%kernel.project_dir%/public/build/bitbag/productAttributeGroups/admin'
```

10. Add encore functions to your templates

```twig
{# @SyliusAdminBundle/_scripts.html.twig #}
{{ encore_entry_script_tags('bitbag-productAttributeGroups-admin', null, 'product_attribute_groups_admin') }}
{# @SyliusAdminBundle/_styles.html.twig #}
{{ encore_entry_link_tags('bitbag-productAttributeGroups-admin', null, 'product_attribute_groups_admin') }}
{# @SyliusShopBundle/_scripts.html.twig #}
{{ encore_entry_script_tags('bitbag-productAttributeGroups-shop', null, 'product_attribute_groups_shop') }}
{# @SyliusShopBundle/_styles.html.twig #}
{{ encore_entry_link_tags('bitbag-productAttributeGroups-shop', null, 'product_attribute_groups_shop') }}
```

11. Override forms:

```
# templates/bundles/SyliusAdminBundle/ProductAttribute/_form.html.twig
{% from '@SyliusAdmin/Macro/translationForm.html.twig' import translationForm %}
{{ form_errors(form) }}
<div class="ui segment">
<div class="four fields">
{{ form_row(form.code) }}
{{ form_row(form.position) }}
{{ form_row(form.type) }}
{{ form_row(form.groups) }}
</div>
{{ form_row(form.translatable) }}
</div>
{% if form.configuration is defined %}
<div class="ui segment">
<h4 class="ui dividing header">{{ 'sylius.ui.configuration'|trans }}</h4>
{% for field in form.configuration %}
{{ form_row(field) }}
{% endfor %}
</div>
{% endif %}
{{ translationForm(form.translations) }}
```

```
# templates/bundles/SyliusAdminBundle/Product/Attribute/attributeChoice.html.twig
---
### Requirements

<div class="ui fluid action input" id="attributeChoice" data-action="{{ path('sylius_admin_render_attribute_forms') }}" style="margin-bottom: 30px;">
{{ form_widget(form, {'attr': {'class': 'ui fluid search dropdown', 'id': 'sylius_product_attribute_choice', 'data-attributes': ''}}) }}
We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.

<button class="ui olive labeled icon floating dropdown button" id="add_attributes_group" data-tab="add_attributes_group" tabindex="0" type="button">
<i class="icon clipboard list"></i> <span class="text"> {{ 'bitbag_sylius_product_attribute_group_plugin.ui.attributes_group'|trans }} </span>
| Package | Version |
|---------------|-----------------|
| PHP | \>=8.0 |
| sylius/sylius | 1.12.x - 1.13.x |
| MySQL | \>= 5.7 |
| NodeJS | \>= 18.x |

<div id="menuWithAttributesGroup" class="menu transition hidden" data-attribute-groups tabindex="-1"></div>
</button>
----

<button class="ui green labeled icon button" type="button">
<i class="icon plus"></i> {{ 'sylius.ui.add_attributes'|trans }}
</button>
</div>
### Full installation guide
- [See the full installation guide](doc/installation.md)

<script>
const urlAttributesGroup = "{{ app.request.schemeAndHttpHost }}/api/v2/shop/shop-attributes-groups"
</script>
```

## Support

Expand Down
147 changes: 147 additions & 0 deletions doc/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
# Installation

## Overview:
GENERAL
- [Requirements](#requirements)
- [Composer](#composer)
- [Basic configuration](#basic-configuration)
---
FRONTEND
- [Templates](#templates)
- [Webpack](#webpack)
---
ADDITIONAL
- [Additional configuration](#additional-configuration)
- [Known Issues](#known-issues)
---

## Requirements:
We work on stable, supported and up-to-date versions of packages. We recommend you to do the same.

| Package | Version |
|---------------|-----------------|
| PHP | \>=8.0 |
| sylius/sylius | 1.12.x - 1.13.x |
| MySQL | \>= 5.7 |
| NodeJS | \>= 18.x |

## Composer:
```bash
composer require bitbag/product-attribute-groups-plugin --no-scripts
```

## Basic configuration:
Add plugin dependencies to your `config/bundles.php` file:

```php
# config/bundles.php

return [
...
BitBag\SyliusProductAttributeGroupsPlugin\BitBagSyliusProductAttributeGroupsPlugin::class => ['all' => true],
];
```

Import required config in your `config/packages/_sylius.yaml` file:

```yaml
# config/packages/_sylius.yaml

imports:
...
- { resource: "@BitBagSyliusProductAttributeGroupsPlugin/Resources/config/config.yml" }
```
Add routing to your `config/routes.yaml` file:
```yaml
# config/routes.yaml
bitbag_product_attribute_groups_plugin:
resource: "@BitBagSyliusProductAttributeGroupsPlugin/Resources/config/routing.yml"
```

### Update your database
First, please run legacy-versioned migrations by using command:
```bash
bin/console doctrine:migrations:migrate
```

After migration, please create a new diff migration and update database:
```bash
bin/console doctrine:migrations:diff
bin/console doctrine:migrations:migrate
```

### Clear application cache by using command:
```bash
bin/console cache:clear
```
**Note:** If you are running it on production, add the `-e prod` flag to this command.

## Templates
Copy required templates into correct directories in your project.

**AdminBundle** (`templates/bundles/SyliusAdminBundle`):
```
vendor/bitbag/product-attribute-groups-plugin/tests/Application/templates/bundles/SyliusAdminBundle/Product/Attribute/attributeChoice.html.twig
vendor/bitbag/product-attribute-groups-plugin/tests/Application/templates/bundles/SyliusAdminBundle/ProductAttribute/_form.html.twig
```
## Webpack
### Webpack.config.js
Please setup your `webpack.config.js` file to require the plugin's webpack configuration. To do so, please put the line below somewhere on top of your webpack.config.js file:
```js
const [ bitbagProductAttributeGroupsAdmin ] = require('./vendor/bitbag/product-attribute-groups-plugin/webpack.config.js')
```
As next step, please add the imported consts into final module exports:
```js
module.exports = [..., bitbagProductAttributeGroupsAdmin];
```

### Assets
Add the asset configuration into `config/packages/assets.yaml`:
```yaml
framework:
assets:
packages:
...
product_attribute_groups_admin:
json_manifest_path: '%kernel.project_dir%/public/build/bitbag/productAttributeGroups/admin/manifest.json'
```
### Webpack Encore
Add the webpack configuration into `config/packages/webpack_encore.yaml`:

```yaml
webpack_encore:
output_path: '%kernel.project_dir%/public/build/default'
builds:
...
product_attribute_groups_admin: '%kernel.project_dir%/public/build/bitbag/productAttributeGroups/admin'
```

### Encore functions
Add encore functions to your templates:

SyliusAdminBundle:
```php
{# @SyliusAdminBundle/_scripts.html.twig #}
{{ encore_entry_script_tags('bitbag-productAttributeGroups-admin', null, 'product_attribute_groups_admin') }}
{# @SyliusAdminBundle/_styles.html.twig #}
{{ encore_entry_link_tags('bitbag-productAttributeGroups-admin', null, 'product_attribute_groups_admin') }}
```

### Run commands
```bash
yarn install
yarn encore dev # or prod, depends on your environment
```

## Known issues
### Translations not displaying correctly
For incorrectly displayed translations, execute the command:
```bash
bin/console cache:clear
```

0 comments on commit 2de4cb7

Please sign in to comment.