### Get Wishlist (Shop API - cURL)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example using cURL to retrieve a wishlist by its token from the Shop API. This demonstrates a GET request to fetch wishlist details and its products.
```bash
# GET /api/v2/shop/wishlists/{token}
curl -X GET "https://your-shop.com/api/v2/shop/wishlists/abc123-token" \
-H "Accept: application/ld+json"
```
--------------------------------
### Get Wishlist Response (Shop API - JSON)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example JSON response when retrieving a wishlist from the Shop API. It includes wishlist details and a list of associated products with their quantities.
```json
{
"@context": "/api/v2/contexts/Wishlist",
"@id": "/api/v2/shop/wishlists/abc123-token",
"@type": "Wishlist",
"id": 5,
"name": "My Wishlist",
"token": "abc123-token",
"wishlistProducts": [
{
"@id": "/api/v2/shop/wishlist-products/1",
"product": "/api/v2/shop/products/PRODUCT_CODE",
"variant": "/api/v2/shop/product-variants/VARIANT_CODE",
"quantity": 1
}
]
}
```
--------------------------------
### List All Wishlists (Admin API - cURL)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example using cURL to retrieve all wishlists in the system via the Admin API. This endpoint requires administrator authentication.
```bash
# GET /api/v2/admin/wishlists
curl -X GET "https://your-shop.com/api/v2/admin/wishlists" \
-H "Accept: application/ld+json" \
-H "Authorization: Bearer {admin_token}"
```
--------------------------------
### Create Wishlist (Shop API - cURL)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example using cURL to create a new wishlist via the Shop API. It demonstrates how to send a POST request with optional token and channel code.
```bash
# POST /api/v2/shop/wishlists
curl -X POST "https://your-shop.com/api/v2/shop/wishlists" \
-H "Content-Type: application/json" \
-H "Accept: application/ld+json" \
-d '{
"tokenValue": "optional-custom-token",
"channelCode": "FASHION_WEB"
}'
```
--------------------------------
### GET /wishlist/add/{productId}
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Adds a product to the user's default wishlist. If no wishlist exists, one is created automatically.
```APIDOC
## GET /wishlist/add/{productId}
### Description
Adds a product to the user's default wishlist by product ID.
### Method
GET
### Endpoint
/wishlist/add/{productId}
### Parameters
#### Path Parameters
- **productId** (integer) - Required - The ID of the product to add to the wishlist.
### Request Example
GET /wishlist/add/42
### Response
#### Success Response (302)
- **Redirect** - Redirects back to the previous page with a success flash message.
```
--------------------------------
### Get Wishlist (Shop API)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Retrieves a specific wishlist by its token, including all associated products and their details.
```APIDOC
## GET /api/v2/shop/wishlists/{token}
### Description
Retrieves a wishlist by its token with all products.
### Method
GET
### Endpoint
/api/v2/shop/wishlists/{token}
### Parameters
#### Path Parameters
- **token** (string) - Required - The unique token identifying the wishlist.
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
curl -X GET "https://your-shop.com/api/v2/shop/wishlists/abc123-token"
```
### Response
#### Success Response (200)
- **@context** (string) - The context URI for the resource.
- **@id** (string) - The resource identifier.
- **@type** (string) - The resource type.
- **id** (integer) - The unique identifier of the wishlist.
- **name** (string) - The name of the wishlist.
- **token** (string) - The token of the wishlist.
- **wishlistProducts** (array) - A list of products in the wishlist.
- **@id** (string) - The resource identifier for the wishlist product.
- **product** (string) - The URI of the product.
- **variant** (string) - The URI of the product variant.
- **quantity** (integer) - The quantity of the product variant in the wishlist.
#### Response Example
```json
{
"@context": "/api/v2/contexts/Wishlist",
"@id": "/api/v2/shop/wishlists/abc123-token",
"@type": "Wishlist",
"id": 5,
"name": "My Wishlist",
"token": "abc123-token",
"wishlistProducts": [
{
"@id": "/api/v2/shop/wishlist-products/1",
"product": "/api/v2/shop/products/PRODUCT_CODE",
"variant": "/api/v2/shop/product-variants/VARIANT_CODE",
"quantity": 1
}
]
}
```
```
--------------------------------
### GET /wishlist/{wishlistId}/add/{productId}
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Adds a product to a specific wishlist identified by its ID.
```APIDOC
## GET /wishlist/{wishlistId}/add/{productId}
### Description
Adds a product to a specific wishlist chosen by the user.
### Method
GET
### Endpoint
/wishlist/{wishlistId}/add/{productId}
### Parameters
#### Path Parameters
- **wishlistId** (integer) - Required - The ID of the target wishlist.
- **productId** (integer) - Required - The ID of the product to add.
### Request Example
GET /wishlist/5/add/42
```
--------------------------------
### GET /wishlist/remove/{productId}
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Removes all instances of a specific product from the current user's wishlist.
```APIDOC
## GET /wishlist/remove/{productId}
### Description
Removes a product from the current wishlist.
### Method
GET
### Endpoint
/wishlist/remove/{productId}
### Parameters
#### Path Parameters
- **productId** (integer) - Required - The ID of the product to remove.
```
--------------------------------
### Create New Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Creates a new wishlist with a custom name. This endpoint can be accessed via GET, POST, or DELETE methods.
```APIDOC
## POST /wishlists/create
### Description
Creates a new wishlist with a custom name via AJAX.
### Method
POST
### Endpoint
/wishlists/create
### Parameters
#### Request Body
- **name** (string) - Required - The name for the new wishlist.
### Request Example
```json
{
"name": "My Birthday List"
}
```
### Response
#### Success Response (200)
- **url** (string) - The URL to the newly created wishlist.
#### Response Example
```json
{
"url": "/en_US/wishlists/6"
}
```
```
--------------------------------
### Add Product to Wishlist (Shop API - cURL)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example using cURL to add a product to a wishlist via a merge-patch request to the Shop API. It specifies the product ID to be added.
```bash
# PATCH /api/v2/shop/wishlists/{token}/product
curl -X PATCH "https://your-shop.com/api/v2/shop/wishlists/abc123-token/product" \
-H "Content-Type: application/merge-patch+json" \
-H "Accept: application/ld+json" \
-d '{
"productId": 42
}'
```
--------------------------------
### GET /wishlist/{wishlistId}/remove/variant/{variantId}
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Removes a specific product variant from a designated wishlist.
```APIDOC
## GET /wishlist/{wishlistId}/remove/variant/{variantId}
### Description
Removes a specific product variant from a wishlist.
### Method
GET
### Endpoint
/wishlist/{wishlistId}/remove/variant/{variantId}
### Parameters
#### Path Parameters
- **wishlistId** (integer) - Required - The ID of the wishlist.
- **variantId** (integer) - Required - The ID of the product variant to remove.
```
--------------------------------
### Edit Wishlist Name
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Updates the name of an existing wishlist. Supports GET, PUT, and POST methods.
```APIDOC
## PUT /wishlists/{id}/edit
### Description
Updates the name of an existing wishlist.
### Method
PUT
### Endpoint
/wishlists/{id}/edit
### Parameters
#### Path Parameters
- **id** (integer) - Required - The ID of the wishlist to edit.
#### Request Body
- **name** (string) - Required - The new name for the wishlist.
### Response
#### Success Response (200)
- (No specific response body detailed, typically indicates success)
#### Response Example
(No example provided in source)
```
--------------------------------
### Delete Wishlist (Shop API - cURL)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example using cURL to delete an entire wishlist via a DELETE request to the Shop API. It requires the wishlist token.
```bash
# DELETE /api/v2/shop/wishlists/{token}
curl -X DELETE "https://your-shop.com/api/v2/shop/wishlists/abc123-token" \
-H "Accept: application/ld+json"
```
--------------------------------
### Add Product Variant to Wishlist (Shop API - cURL)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example using cURL to add a specific product variant to a wishlist via a merge-patch request to the Shop API. It specifies the product variant ID.
```bash
# PATCH /api/v2/shop/wishlists/{token}/variant
curl -X PATCH "https://your-shop.com/api/v2/shop/wishlists/abc123-token/variant" \
-H "Content-Type: application/merge-patch+json" \
-H "Accept: application/ld+json" \
-d '{
"productVariantId": 15
}'
```
--------------------------------
### Remove Product from Wishlist (Shop API - cURL)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example using cURL to remove a product from a wishlist via a DELETE request to the Shop API. It requires the wishlist token and the product ID.
```bash
# DELETE /api/v2/shop/wishlists/{token}/products/{productId}
curl -X DELETE "https://your-shop.com/api/v2/shop/wishlists/abc123-token/products/42" \
-H "Accept: application/ld+json"
```
--------------------------------
### Remove Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Deletes an entire wishlist. Supports GET, POST, and DELETE methods. CSRF protection is disabled for this endpoint.
```APIDOC
## DELETE /wishlists/{id}/remove
### Description
Deletes an entire wishlist.
### Method
DELETE
### Endpoint
/wishlists/{id}/remove
### Parameters
#### Path Parameters
- **id** (integer) - Required - The ID of the wishlist to remove.
### Response
#### Success Response (200)
- (No specific response body detailed, typically indicates success and a redirect)
#### Response Example
(No example provided in source)
```
--------------------------------
### Remove Product Variant from Wishlist (Shop API - cURL)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Example using cURL to remove a specific product variant from a wishlist via a DELETE request to the Shop API. It requires the wishlist token and the product variant ID.
```bash
# DELETE /api/v2/shop/wishlists/{token}/productVariants/{productVariantId}
curl -X DELETE "https://your-shop.com/api/v2/shop/wishlists/abc123-token/productVariants/15" \
-H "Accept: application/ld+json"
```
--------------------------------
### Accessing Wishlist Variable in Twig Templates (Sylius)
Source: https://github.com/sylius/wishlistplugin/blob/1.2/UPGRADE-1.1.md
Demonstrates the change in accessing the 'wishlist' variable in Sylius Twig templates between versions 1.0 and 1.1. In 1.0, 'wishlist' was a direct variable, while in 1.1, it's accessed via 'hookable_metadata.context.wishlist'. This change requires updating template overrides.
```twig
{# Before (1.0): #}
{{ wishlist.id }}
{# After (1.1): #}
{% set wishlist = hookable_metadata.context.wishlist %}
{{ wishlist.id }}
```
--------------------------------
### Create Wishlist Instances using WishlistFactoryInterface
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Provides methods to instantiate new wishlist objects. It supports creating empty instances, wishlists associated with a specific user, and channel-aware wishlists for multi-store environments.
```php
use Sylius\WishlistPlugin\Factory\WishlistFactoryInterface;
$wishlistFactory->createNew(); // Creates empty Wishlist instance
$wishlistFactory->createForUser($shopUser); // Creates wishlist associated with user
$wishlistFactory->createForUserAndChannel($shopUser, $channel);
```
--------------------------------
### Create New Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Defines the route for creating a new wishlist and demonstrates the PHP implementation using the Command Bus to dispatch a creation command.
```yaml
wishlist_create_new_wishlist:
path: /wishlists/create
methods: [GET, POST, DELETE]
defaults:
_controller: sylius_wishlist_plugin.controller.action.create_new_wishlist
```
```php
use Sylius\WishlistPlugin\Command\Wishlist\CreateNewWishlist;
$createNewWishlist = new CreateNewWishlist($wishlistName, $channel->getCode());
$envelope = $this->commandBus->dispatch($createNewWishlist);
```
--------------------------------
### Manage Wishlist Entity
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Demonstrates how to instantiate a Wishlist, associate it with users or channels, and manage product items. It supports both authenticated and anonymous session-based wishlists.
```php
use Sylius\WishlistPlugin\Entity\Wishlist;
use Sylius\WishlistPlugin\Entity\WishlistInterface;
$wishlist = new Wishlist();
$wishlist->setName('Birthday List');
$wishlist->setChannel($channel);
$wishlist->setShopUser($shopUser);
$wishlist->addWishlistProduct($wishlistProduct);
if ($wishlist->hasProduct($product)) {
// Product exists
}
$wishlist->removeProduct($wishlistProduct);
$wishlist->clear();
$token = $wishlist->getToken();
```
--------------------------------
### Add Product to Wishlist Action
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Demonstrates the logic for adding a product to the default wishlist. It resolves the current wishlist, creates a wishlist product entity, and persists the changes.
```php
$product = $this->productRepository->find($request->get('productId'));
$wishlists = $this->wishlistsResolver->resolveAndCreate();
$wishlist = array_shift($wishlists);
/** @var WishlistProductInterface $wishlistProduct */
$wishlistProduct = $this->wishlistProductFactory->createForWishlistAndProduct($wishlist, $product);
$wishlist->addWishlistProduct($wishlistProduct);
$this->wishlistManager->flush();
```
--------------------------------
### Create Wishlist Product Entries using WishlistProductFactoryInterface
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Defines the factory methods for generating wishlist product items. It allows for the creation of generic entries or entries specifically linked to a product or a product variant within a wishlist.
```php
use Sylius\WishlistPlugin\Factory\WishlistProductFactoryInterface;
$wishlistProductFactory->createNew();
$wishlistProductFactory->createForWishlistAndProduct($wishlist, $product);
$wishlistProductFactory->createForWishlistAndVariant($wishlist, $productVariant);
```
--------------------------------
### Import Wishlist from CSV
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the route and command implementation for importing products into a wishlist from an uploaded CSV file.
```yaml
wishlist_import_from_csv:
path: /wishlist/csv/import
defaults:
_controller: sylius_wishlist_plugin.controller.action.import_from_csv
```
```php
use Sylius\WishlistPlugin\Command\Wishlist\ImportWishlistFromCsv;
$command = new ImportWishlistFromCsv($file->getFileInfo(), $request, (int) $wishlist->getId());
return $this->handle($command);
```
--------------------------------
### Export Wishlist to PDF
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the route and command implementation for generating a downloadable PDF file from selected wishlist items.
```yaml
wishlist_export_to_pdf:
path: /wishlist/{wishlistId}/export/pdf
defaults:
_controller: sylius_wishlist_plugin.controller.action.export_wishlist_to_pdf_action
```
```php
use Sylius\WishlistPlugin\Command\Wishlist\ExportSelectedProductsFromWishlistToPdf;
$command = new ExportSelectedProductsFromWishlistToPdf($form->getData());
$this->messageBus->dispatch($command);
```
--------------------------------
### List Wishlist Products Route and Usage
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the route to display the primary wishlist and provides an overview of the controller action. This endpoint renders a template containing the wishlist items and a management form.
```yaml
wishlist_list_products:
path: /wishlist
methods: [GET]
defaults:
_controller: sylius_wishlist_plugin.controller.action.list_wishlist_products
```
--------------------------------
### Query Wishlists via Repository
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Provides methods to retrieve wishlists based on user identity, anonymous tokens, channel context, or specific names. Includes cleanup utilities for expired guest wishlists.
```php
use Sylius\WishlistPlugin\Repository\WishlistRepositoryInterface;
$wishlist = $wishlistRepository->findOneByShopUser($shopUser);
$wishlists = $wishlistRepository->findAllByToken($token);
$wishlists = $wishlistRepository->findAllByShopUserAndChannel($shopUser, $channel);
$oldWishlists = $wishlistRepository->findAllAnonymousUpdatedAtEarlierThan($dateTime);
```
--------------------------------
### Import Wishlist from CSV
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Imports products into a wishlist from an uploaded CSV file. Requires multipart/form-data.
```APIDOC
## POST /wishlist/csv/import
### Description
Imports products into a wishlist from an uploaded CSV file.
### Method
POST
### Endpoint
/wishlist/csv/import
### Parameters
#### Request Body
- **wishlist_file** (file) - Required - The CSV file containing the products to import.
- **targetWishlistId** (integer) - Required - The ID of the wishlist to import products into.
### Request Example
(This is a multipart/form-data request, not a JSON body)
### Response
#### Success Response (200)
- (No specific response body detailed, typically indicates success)
#### Response Example
(No example provided in source)
```
--------------------------------
### Manage WishlistProduct Entity
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Handles individual product items within a wishlist, including quantity tracking and associations with specific product variants.
```php
use Sylius\WishlistPlugin\Entity\WishlistProduct;
use Sylius\WishlistPlugin\Entity\WishlistProductInterface;
$wishlistProduct = new WishlistProduct();
$wishlistProduct->setWishlist($wishlist);
$wishlistProduct->setProduct($product);
$wishlistProduct->setVariant($productVariant);
$wishlistProduct->setQuantity(2);
$quantity = $wishlistProduct->getQuantity();
```
--------------------------------
### Copy Selected Products to Another Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the routing and command implementation for copying items between two different wishlists.
```yaml
wishlist_copy_selected_products_to_other_wishlist:
path: /wishlists/{wishlistId}/copy/{destinedWishlistId}
methods: [POST]
defaults:
_controller: sylius_wishlist_plugin.controller.action.copy_selected_products_to_other_wishlist
```
```php
use Sylius\WishlistPlugin\Command\Wishlist\CopySelectedProductsToOtherWishlist;
$copyProductsToAnotherWishlist = new CopySelectedProductsToOtherWishlist($selectedProducts, $destinedWishlist);
$this->commandBus->dispatch($copyProductsToAnotherWishlist);
```
--------------------------------
### Create Wishlist (Shop API)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Creates a new wishlist for the current user or an anonymous session. You can optionally provide a custom token value and specify the channel code.
```APIDOC
## POST /api/v2/shop/wishlists
### Description
Creates a new wishlist for the current user or anonymous session.
### Method
POST
### Endpoint
/api/v2/shop/wishlists
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
- **tokenValue** (string) - Optional - A custom token value for the wishlist.
- **channelCode** (string) - Optional - The code of the channel for which the wishlist is created.
### Request Example
```json
{
"tokenValue": "optional-custom-token",
"channelCode": "FASHION_WEB"
}
```
### Response
#### Success Response (200 or 201)
(Response structure not provided in source, typically returns the created wishlist object)
#### Response Example
```json
{
"@context": "/api/v2/contexts/Wishlist",
"@id": "/api/v2/shop/wishlists/some-token",
"@type": "Wishlist",
"token": "some-token",
"channelCode": "FASHION_WEB",
"wishlistProducts": []
}
```
```
--------------------------------
### List All Wishlists (Admin API)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Retrieves a list of all wishlists in the system. This endpoint is restricted to administrators.
```APIDOC
## GET /api/v2/admin/wishlists
### Description
Retrieves all wishlists in the system (admin only).
### Method
GET
### Endpoint
/api/v2/admin/wishlists
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
curl -X GET "https://your-shop.com/api/v2/admin/wishlists"
-H "Authorization: Bearer {admin_token}"
```
### Response
#### Success Response (200)
(Response structure not provided in source, typically returns a collection of wishlist objects)
#### Response Example
```json
[
{
"@context": "/api/v2/contexts/Wishlist",
"@id": "/api/v2/admin/wishlists/1",
"@type": "Wishlist",
"id": 1,
"token": "wishlist-token-1",
"customer": "/api/v2/admin/customers/1"
}
]
```
```
--------------------------------
### Add Selected Products to Cart
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Provides the route and command implementation for moving selected items from a wishlist into the shopping cart.
```yaml
wishlist_add_selected_products:
path: /wishlist/{wishlistId}/products/add
defaults:
_controller: sylius_wishlist_plugin.controller.action.add_selected_products_to_cart
```
```php
use Sylius\WishlistPlugin\Command\Wishlist\AddSelectedProductsToCart;
$command = new AddSelectedProductsToCart($form->getData());
$this->messageBus->dispatch($command);
```
--------------------------------
### List All Wishlists Route
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Defines the route to retrieve and display all wishlists associated with the current user session or anonymous visitor.
```yaml
wishlist_list_wishlists:
path: /wishlists
defaults:
_controller: sylius_wishlist_plugin.controller.action.list_wishlists
```
--------------------------------
### Twig Template for AddToWishlistComponent
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This is a Twig template snippet demonstrating how to use the AddToWishlistComponent in your Symfony application. It shows the basic usage with product and variant attributes.
```twig
{# Using the component in templates #}
```
--------------------------------
### Export Wishlist to CSV
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the route and command implementation for exporting wishlist items into a CSV file format.
```yaml
wishlsit_export_selected_products_to_csv:
path: /wishlist/{wishlistId}/csv/export
defaults:
_controller: sylius_wishlist_plugin.controller.action.export_selected_products_to_csv
```
```php
use Sylius\WishlistPlugin\Command\Wishlist\ExportWishlistToCsv;
$file = new \SplFileObject(sprintf('%s.csv', $wishlistName), 'w+');
$command = new ExportWishlistToCsv($form->getData(), $file);
$csvFile = $this->handle($command);
```
--------------------------------
### Export Wishlist to CSV
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Exports selected wishlist products to a downloadable CSV file. The response is a binary file.
```APIDOC
## POST /wishlist/{wishlistId}/csv/export
### Description
Exports selected wishlist products to a downloadable CSV file.
### Method
POST
### Endpoint
/wishlist/{wishlistId}/csv/export
### Parameters
#### Path Parameters
- **wishlistId** (integer) - Required - The ID of the wishlist to export.
#### Request Body
- **selectedItems** (array) - Optional - A list of items to include in the CSV export. If not provided, all items might be exported.
### Request Example
```json
{
"selectedItems": [
"product_sku_1",
"product_sku_3"
]
}
```
### Response
#### Success Response (200)
- **Content-Disposition** (header) - `attachment; filename="Wishlist.csv"`
- **Content-Type** (header) - `text/csv`
#### Response Example
(Response is a CSV file download, not a JSON body)
```
--------------------------------
### Export Wishlist to PDF
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Exports selected wishlist products to a downloadable PDF file. The selection of products is typically done via form data.
```APIDOC
## POST /wishlist/{wishlistId}/export/pdf
### Description
Exports selected wishlist products to a downloadable PDF file.
### Method
POST
### Endpoint
/wishlist/{wishlistId}/export/pdf
### Parameters
#### Path Parameters
- **wishlistId** (integer) - Required - The ID of the wishlist to export.
#### Request Body
- **selectedItems** (array) - Optional - A list of items to include in the PDF export. If not provided, all items might be exported.
### Request Example
```json
{
"selectedItems": [
"product_sku_1",
"product_sku_3"
]
}
```
### Response
#### Success Response (200)
- **Content-Disposition** (header) - Indicates the file is an attachment and provides the filename.
- **Content-Type** (header) - `application/pdf`
#### Response Example
(Response is a PDF file download, not a JSON body)
```
--------------------------------
### Sylius Wishlist Plugin Configuration YAML
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This YAML configuration file (`sylius_wishlist_plugin.yaml`) allows you to customize the behavior of the Sylius Wishlist Plugin. It includes settings for the wishlist cookie token, allowed MIME types for CSV import, and resource configurations for wishlist and wishlist products.
```yaml
# config/packages/sylius_wishlist_plugin.yaml
sylius_wishlist_plugin:
# Cookie name for storing anonymous wishlist token
wishlist_cookie_token: 'wishlist_cookie_token'
# Allowed MIME types for CSV import
allowed_mime_types:
- 'text/csv'
- 'text/plain'
- 'application/csv'
- 'text/comma-separated-values'
- 'application/excel'
- 'application/vnd.ms-excel'
- 'application/vnd.msexcel'
- 'text/anytext'
- 'application/octet-stream'
- 'application/txt'
# Resource configuration
resources:
wishlist:
classes:
model: Sylius\WishlistPlugin\Entity\Wishlist
interface: Sylius\WishlistPlugin\Entity\WishlistInterface
repository: Sylius\WishlistPlugin\Repository\WishlistRepository
controller: Sylius\Bundle\ResourceBundle\Controller\ResourceController
factory: Sylius\Component\Resource\Factory\Factory
wishlist_product:
classes:
model: Sylius\WishlistPlugin\Entity\WishlistProduct
interface: Sylius\WishlistPlugin\Entity\WishlistProductInterface
repository: Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository
```
--------------------------------
### Symfony Live Component for Adding Products to Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This PHP component, using Symfony UX LiveComponent, handles adding products to a wishlist. It listens for variant changes and provides an action to add the current variant to a wishlist, returning a redirect response.
```php
use Sylius\WishlistPlugin\Twig\Component\Product\AddToWishlistComponent;
use Symfony\UX\LiveComponent\Attribute\AsLiveComponent;
use Symfony\UX\LiveComponent\Attribute\LiveAction;
use Symfony\UX\LiveComponent\Attribute\LiveArg;
use Symfony\UX\LiveComponent\Attribute\LiveListener;
#[AsLiveComponent]
final class AddToWishlistComponent
{
// Automatically updates when variant changes in AddToCartFormComponent
#[LiveListener(AddToCartFormComponent::SYLIUS_SHOP_VARIANT_CHANGED)]
public function updateProductVariant(#[LiveArg] mixed $variantId): void
{
$this->variant = $this->productVariantRepository->find($variantId);
}
// Add current variant to wishlist
#[LiveAction]
public function addToWishlist(#[LiveArg] ?int $wishlistId = null): RedirectResponse
{
return $this->addProductVariantToWishlistProcessor->process(
$this->variant,
$wishlistId,
);
}
}
```
--------------------------------
### Integrate Wishlists in Twig Templates
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Utilize built-in Twig functions to fetch and display wishlist data directly in templates. Useful for headers, counters, and user-specific wishlist views.
```twig
{% set user_wishlists = findAllByShopUser(app.user) %}
{% set channel_wishlists = findAllByShopUserAndChannel(app.user, sylius.channel) %}
Wishlists ({{ wishlists|length }})
```
--------------------------------
### CreateNewWishlistSubscriber Description
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This describes the `CreateNewWishlistSubscriber` for the Sylius Wishlist Plugin. It's an event subscriber that listens to `kernel.response` events. Its primary function is to automatically create a new wishlist and set a cookie token for anonymous users.
```php
use Sylius\WishlistPlugin\EventSubscriber\CreateNewWishlistSubscriber;
// Subscribes to kernel.response events
// Creates wishlist and sets cookie token for anonymous users
```
--------------------------------
### Symfony Console Command to Remove Guest Wishlists
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This Bash command-line interface (CLI) command is used to clean up anonymous wishlists from the system. It can remove all guest wishlists or filter them by a specific update date.
```bash
# Remove all guest wishlists
bin/console sylius:wishlist:remove-guest-wishlists
# Remove guest wishlists updated before a specific date
bin/console sylius:wishlist:remove-guest-wishlists --date=01-01-2024
bin/console sylius:wishlist:remove-guest-wishlists -d 15-06-2024
```
--------------------------------
### Associate Anonymous Wishlist with User Account (YAML)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Defines the route for associating an anonymous wishlist with a logged-in user's account. This endpoint allows for the persistence of wishlists when a user logs in.
```yaml
wishlist_add_wishlist_to_user:
path: /wishlists/{id}/save-wishlist
methods: [GET, PUT, POST]
defaults:
_controller: sylius_wishlist_plugin.controller.action.add_wishlists_to_user
```
--------------------------------
### Show Chosen Wishlist Route
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the route to display the contents of a specific wishlist identified by its ID. This route is used for viewing detailed wishlist management pages.
```yaml
wishlist_show_chosen_wishlist:
path: /wishlists/{wishlistId}
defaults:
_controller: sylius_wishlist_plugin.controller.action.show_chosen_wishlist
```
--------------------------------
### Add Selected Products to Cart
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Adds selected wishlist items to the shopping cart with specified quantities. Handles potential stock and quantity exceptions.
```APIDOC
## POST /wishlist/{wishlistId}/products/add
### Description
Adds selected wishlist items to the shopping cart with specified quantities.
### Method
POST
### Endpoint
/wishlist/{wishlistId}/products/add
### Parameters
#### Path Parameters
- **wishlistId** (integer) - Required - The ID of the wishlist from which to add products.
#### Request Body
- **items** (array) - Required - An array of items to add, typically containing product IDs, quantities, and selection status.
### Request Example
```json
{
"items": [
{
"productId": 123,
"quantity": 2,
"selected": true
}
]
}
```
### Response
#### Success Response (200)
- (No specific response body detailed, typically indicates success)
#### Response Example
(No example provided in source)
```
--------------------------------
### Update Wishlist Product Quantities (YAML)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Defines the route for updating quantities of products within a wishlist. This configuration is typically used in a Symfony application to map a URL path to a specific controller action.
```yaml
wishlist_save_products:
path: /wishlist/{wishlistId}/products/save
defaults:
_controller: sylius_wishlist_plugin.controller.action.update_wishlist_products_quantity
```
--------------------------------
### Add Product to Selected Wishlist Route
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Defines the route for adding a specific product to a user-selected wishlist by ID. This allows users to organize products into multiple custom wishlists.
```yaml
wishlist_add_product_to_selected_wishlist:
path: /wishlist/{wishlistId}/add/{productId}
defaults:
_controller: sylius_wishlist_plugin.controller.action.add_product_to_selected_wishlist
```
--------------------------------
### Copy Selected Products to Another Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Copies selected items from one wishlist to another specified wishlist. This operation is performed via a POST request.
```APIDOC
## POST /wishlists/{wishlistId}/copy/{destinedWishlistId}
### Description
Copies selected items from one wishlist to another.
### Method
POST
### Endpoint
/wishlists/{wishlistId}/copy/{destinedWishlistId}
### Parameters
#### Path Parameters
- **wishlistId** (integer) - Required - The ID of the source wishlist.
- **destinedWishlistId** (integer) - Required - The ID of the destination wishlist.
#### Request Body
- **selectedProducts** (array) - Required - A list of products to copy from the source wishlist.
### Request Example
```json
{
"selectedProducts": [
101,
105
]
}
```
### Response
#### Success Response (200)
- (No specific response body detailed, typically indicates success)
#### Response Example
(No example provided in source)
```
--------------------------------
### Add Wishlist to User Account
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Associates an anonymous wishlist with a logged-in user's account. This is useful for persisting a guest user's wishlist when they decide to register or log in.
```APIDOC
## POST /wishlists/{id}/save-wishlist
### Description
Associates an anonymous wishlist with a logged-in user's account.
### Method
GET, PUT, POST
### Endpoint
/wishlists/{id}/save-wishlist
### Parameters
#### Path Parameters
- **id** (integer) - Required - The ID of the wishlist to associate.
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
curl -X POST "https://your-shop.com/wishlists/123/save-wishlist"
```
### Response
#### Success Response (200)
(Response structure not provided in source, typically indicates success or returns the updated wishlist)
#### Response Example
```json
{
"message": "Wishlist associated with user account."
}
```
```
--------------------------------
### Save Wishlist Product Quantities
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Updates the quantities of products within a specific wishlist. This endpoint allows for batch updates to product quantities in a user's wishlist.
```APIDOC
## POST /wishlist/{wishlistId}/products/save
### Description
Updates quantities for products in a wishlist.
### Method
POST
### Endpoint
/wishlist/{wishlistId}/products/save
### Parameters
#### Path Parameters
- **wishlistId** (integer) - Required - The ID of the wishlist to update.
#### Query Parameters
None
#### Request Body
(Structure not provided in source, typically contains product IDs and new quantities)
### Request Example
```json
{
"product_id_1": 5,
"product_id_2": 2
}
```
### Response
#### Success Response (200)
(Response structure not provided in source, typically indicates success or returns updated wishlist data)
#### Response Example
```json
{
"message": "Wishlist quantities updated successfully."
}
```
```
--------------------------------
### Add Product to Wishlist (Shop API)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Adds a product to a specified wishlist using its product ID. This performs a merge-patch operation.
```APIDOC
## PATCH /api/v2/shop/wishlists/{token}/product
### Description
Adds a product to a wishlist by product ID.
### Method
PATCH
### Endpoint
/api/v2/shop/wishlists/{token}/product
### Parameters
#### Path Parameters
- **token** (string) - Required - The unique token identifying the wishlist.
#### Query Parameters
None
#### Request Body
- **productId** (integer) - Required - The ID of the product to add to the wishlist.
### Request Example
```json
{
"productId": 42
}
```
### Response
#### Success Response (200)
(Response structure not provided in source, typically returns the updated wishlist or a success message)
#### Response Example
```json
{
"message": "Product added to wishlist."
}
```
```
--------------------------------
### Create Wishlist DTO (Shop API - PHP)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
The Data Transfer Object (DTO) used for creating a wishlist in the Shop API. It defines the expected structure for the request payload.
```php
// Request DTO
use Sylius\WishlistPlugin\Command\Wishlist\CreateWishlist;
final class CreateWishlist implements WishlistSyncCommandInterface
{
public function __construct(
public ?string $tokenValue,
public ?string $channelCode,
) {}
}
// Serialization groups: sylius_wishlist:shop:wishlist:create
```
--------------------------------
### LoggedUserWishlistSubscriber Description
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This describes the `LoggedUserWishlistSubscriber` for the Sylius Wishlist Plugin. It subscribes to the `security.interactive_login` event. Its purpose is to merge anonymous wishlists with the authenticated user's wishlist upon login, ensuring data consistency.
```php
use Sylius\WishlistPlugin\EventSubscriber\LoggedUserWishlistSubscriber;
// Subscribes to security.interactive_login
// Associates anonymous wishlists with the authenticated user
// Merges products from anonymous wishlist into user's existing wishlist
```
--------------------------------
### Custom Entity Configuration for Sylius Wishlist Plugin
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This YAML configuration snippet updates the Sylius Wishlist Plugin to use a custom `Wishlist` entity class. By specifying `App\Entity\Wishlist` under `sylius_wishlist_plugin.resources.wishlist.classes.model`, you can leverage your custom entity.
```yaml
# config/packages/sylius_wishlist_plugin.yaml
sylius_wishlist_plugin:
resources:
wishlist:
classes:
model: App\Entity\Wishlist
```
--------------------------------
### Add Product to Wishlist DTO (Shop API - PHP)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
The Data Transfer Object (DTO) for adding a product to a wishlist in the Shop API. It contains the product ID to be added.
```php
// Request DTO
use Sylius\WishlistPlugin\Command\Wishlist\AddProductToWishlist;
final class AddProductToWishlist implements WishlistTokenValueAwareInterface
{
public function __construct(public int $productId) {}
}
// Security: is_granted('update', object)
// Serialization groups: sylius_wishlist:shop:wishlist:add_product
```
--------------------------------
### PHP Command Definition for RemoveGuestWishlistsCommand
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This PHP code defines the `RemoveGuestWishlistsCommand` for Symfony Console. It registers the command with a name and description, and adds an optional `--date` argument for filtering.
```php
// Command definition
#[AsCommand(
name: 'sylius:wishlist:remove-guest-wishlists',
description: 'Removes guest wishlists',
)]
final class RemoveGuestWishlistsCommand extends Command
{
protected function configure(): void
{
$this->addOption(
'date',
'd',
InputOption::VALUE_OPTIONAL,
'The date to remove wishlists updated before (format: d-m-Y)',
);
}
}
// Output: "Removed 42 guest wishlists"
```
--------------------------------
### Remove Product from Wishlist Action
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Handles the removal of a product from the current wishlist. It iterates through the collection of wishlist products and removes those matching the specified product ID.
```php
foreach ($wishlist->getWishlistProducts() as $wishlistProduct) {
if ($product === $wishlistProduct->getProduct()) {
$this->wishlistProductManager->remove($wishlistProduct);
}
}
$this->wishlistProductManager->flush();
```
--------------------------------
### Clear Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Removes all products from a wishlist without deleting the wishlist itself.
```APIDOC
## POST /wishlist/clear/{wishlistId}
### Description
Removes all products from a wishlist without deleting the wishlist itself.
### Method
POST
### Endpoint
/wishlist/clear/{wishlistId}
### Parameters
#### Path Parameters
- **wishlistId** (integer) - Required - The ID of the wishlist to clear.
### Response
#### Success Response (200)
- (No specific response body detailed, typically indicates success)
#### Response Example
(No example provided in source)
```
--------------------------------
### Clear Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the route to remove all products from a specific wishlist without deleting the wishlist entity itself.
```yaml
wishlist_clean:
path: /wishlist/clear/{wishlistId}
defaults:
_controller: sylius_wishlist_plugin.controller.action.clean_wishlist
```
--------------------------------
### Add Product Variant to Wishlist DTO (Shop API - PHP)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
The Data Transfer Object (DTO) for adding a product variant to a wishlist in the Shop API. It includes the product variant ID.
```php
// Request DTO
use Sylius\WishlistPlugin\Command\Wishlist\AddProductVariantToWishlist;
final class AddProductVariantToWishlist implements WishlistTokenValueAwareInterface
{
public function __construct(public int $productVariantId) {}
}
```
--------------------------------
### Add Product Variant to Wishlist (Shop API)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Adds a specific product variant to a wishlist using its product variant ID. This uses a merge-patch operation.
```APIDOC
## PATCH /api/v2/shop/wishlists/{token}/variant
### Description
Adds a specific product variant to a wishlist.
### Method
PATCH
### Endpoint
/api/v2/shop/wishlists/{token}/variant
### Parameters
#### Path Parameters
- **token** (string) - Required - The unique token identifying the wishlist.
#### Query Parameters
None
#### Request Body
- **productVariantId** (integer) - Required - The ID of the product variant to add to the wishlist.
### Request Example
```json
{
"productVariantId": 15
}
```
### Response
#### Success Response (200)
(Response structure not provided in source, typically returns the updated wishlist or a success message)
#### Response Example
```json
{
"message": "Product variant added to wishlist."
}
```
```
--------------------------------
### Remove Wishlist
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the routing for deleting a wishlist, including CSRF protection settings and post-deletion redirection.
```yaml
wishlist_remove_wishlist:
path: /wishlists/{id}/remove
methods: [GET, POST, DELETE]
defaults:
_controller: sylius_wishlist_plugin.controller.wishlist::deleteAction
_sylius:
csrf_protection: false
flash: sylius_wishlist_plugin.ui.remove_wishlist
redirect:
route: wishlist_list_wishlists
```
--------------------------------
### Delete Wishlist Security Check (Shop API - PHP)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Indicates the security check required before deleting a wishlist via the Shop API. This ensures proper authorization.
```php
// Security: is_granted('delete', object)
```
--------------------------------
### Edit Wishlist Name
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the routing for updating the name of an existing wishlist via a PUT or POST request.
```yaml
wishlist_edit_wishlist_name:
path: /wishlists/{id}/edit
methods: [GET, PUT, POST]
defaults:
_controller: sylius_wishlist_plugin.controller.action.update_wishlist_name_action
```
--------------------------------
### Remove Product from Wishlist (Shop API)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Removes a specific product from a wishlist. This is a DELETE operation.
```APIDOC
## DELETE /api/v2/shop/wishlists/{token}/products/{productId}
### Description
Removes a product from a wishlist.
### Method
DELETE
### Endpoint
/api/v2/shop/wishlists/{token}/products/{productId}
### Parameters
#### Path Parameters
- **token** (string) - Required - The unique token identifying the wishlist.
- **productId** (integer) - Required - The ID of the product to remove from the wishlist.
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
curl -X DELETE "https://your-shop.com/api/v2/shop/wishlists/abc123-token/products/42"
```
### Response
#### Success Response (204 No Content)
(Typically no response body for a successful deletion)
#### Response Example
(No content)
```
--------------------------------
### Custom Wishlist Entity Class in PHP
Source: https://context7.com/sylius/wishlistplugin/llms.txt
This PHP code defines a custom `Wishlist` entity that extends the base `SyliusWishlistPluginEntityWishlist`. It adds a new property `isPublic` with getter and setter methods, allowing for custom wishlist behavior.
```php
// src/Entity/Wishlist.php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Sylius\WishlistPlugin\Entity\Wishlist as BaseWishlist;
#[ORM\Entity]
#[ORM\Table(name: 'sylius_wishlist')]
class Wishlist extends BaseWishlist
{
#[ORM\Column(type: 'boolean')]
private bool $isPublic = false;
public function isPublic(): bool
{
return $this->isPublic;
}
public function setPublic(bool $isPublic): void
{
$this->isPublic = $isPublic;
}
}
```
--------------------------------
### Remove Product Variant from Wishlist Route
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Configures the route for removing a specific product variant from a designated wishlist. This is useful for stores with complex product variations.
```yaml
wishlist_remove_product_variant:
path: /wishlist/{wishlistId}/remove/variant/{variantId}
defaults:
_controller: sylius_wishlist_plugin.controller.action.remove_product_variant_from_wishlist
```
--------------------------------
### Delete Wishlist (Shop API)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Deletes an entire wishlist identified by its token. This is a DELETE operation.
```APIDOC
## DELETE /api/v2/shop/wishlists/{token}
### Description
Deletes an entire wishlist.
### Method
DELETE
### Endpoint
/api/v2/shop/wishlists/{token}
### Parameters
#### Path Parameters
- **token** (string) - Required - The unique token identifying the wishlist to delete.
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
curl -X DELETE "https://your-shop.com/api/v2/shop/wishlists/abc123-token"
```
### Response
#### Success Response (204 No Content)
(Typically no response body for a successful deletion)
#### Response Example
(No content)
```
--------------------------------
### Remove Product Variant from Wishlist (Shop API)
Source: https://context7.com/sylius/wishlistplugin/llms.txt
Removes a specific product variant from a wishlist using its product variant ID. This is a DELETE operation.
```APIDOC
## DELETE /api/v2/shop/wishlists/{token}/productVariants/{productVariantId}
### Description
Removes a specific product variant from a wishlist.
### Method
DELETE
### Endpoint
/api/v2/shop/wishlists/{token}/productVariants/{productVariantId}
### Parameters
#### Path Parameters
- **token** (string) - Required - The unique token identifying the wishlist.
- **productVariantId** (integer) - Required - The ID of the product variant to remove from the wishlist.
#### Query Parameters
None
#### Request Body
None
### Request Example
```bash
curl -X DELETE "https://your-shop.com/api/v2/shop/wishlists/abc123-token/productVariants/15"
```
### Response
#### Success Response (204 No Content)
(Typically no response body for a successful deletion)
#### Response Example
(No content)
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.