Install shopping list¶
Install framework¶
Run the following command to install the package:
1 | |
The associated Symfony Flex recipe configures the bundle and its routes.
Check that the following line has been added by the recipe to config/bundles.php file's array:
1 2 3 4 | |
And that you have a config/routes/ibexa_shopping_list.yaml file configuring the following routes:
1 2 3 4 5 6 | |
Modify database schema¶
Ibexa Doctrine migrations manage the database schema for this package.
-
To see a list of known migrations, and find out which ones are pending for the whole project, run:
1php bin/console ibexa:doctrine:migrations:versions -
To preview the changes before you apply them, use
--dry-runwith--write-sql:1php bin/console ibexa:doctrine:migrations:migrate --dry-run --write-sql=var/migration-preview.sql
Preview only
This generates an SQL file that is only intended for review. More recent migrations can be unaware of changes made by earlier migrations in the same run, so the file may be incomplete. Do not run the SQL file against your database.
Always apply changes by running the command without the --dry-run flag.
-
To apply pending migrations:
1php bin/console ibexa:doctrine:migrations:migrateThis command does more than create the Shopping list tables - it applies all pending migrations for the project.
The
ibexa:doctrine:migrations:migratecommand creates the required data structures, but doesn't add any data to the database.
Apply migrations one by one
Instead of applying all pending migrations at once, you can go through them one at a time. To preview only the next pending migration, run:
1 | |
Then, to apply it, run the same command without the --dry-run option:
1 | |
Repeat these steps until no pending migrations remain.
To check which migrations are still pending, run php bin/console ibexa:doctrine:migrations:status.
Initially, users don't have any shopping lists, not even the default “My Wishlist” list. The default shopping list is created automatically when the user triggers the "Add to wishlist" action for the first time.
Configure¶
By default, the maximum shopping list count per user is 10 and the maximum entries per list is 100. When listing their shopping lists, the user see 25 lists per page (and as it's over the shopping list count, there is always one page of shopping lists in this default scenario).
You can override the following parameters to change their values:
1 2 3 4 | |
Max lists per user and default shopping list
The customer can always create the default shopping list if it doesn't exist yet, even if they have already reached the limit defined by max_lists_per_user.
So, for 10 as the default limit, the user may have 11 lists if the user created 10 custom lists before creating the default one.
If you want to restrict users to only the default shopping list, you can set max_lists_per_user to 0.
Shopping list user role¶
To allow customers to use the shopping list feature, create a new role and assign it to registered customer groups. To restrict authenticated users access to only their own lists, you must grant the four functions from the Shopping List module with the limitation 'Shopping List Owner: Self'. Otherwise, they will be able to interact with all shopping lists existing in the system. Anonymous users can't have shopping lists as they're internally sharing the same account.
To create such role, you can use a migration file, for example, with the following content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | |
On a clean install, you can, for example, assign this "Shopping List User" role to the "Customers" user group.
After placing the migration content in src/Migrations/Ibexa/migrations/shopping_list_user.yaml, you can import and execute it with:
1 | |