Skip to main content
Version: 4.0

Storage List Bundle

The Storage List Bundle assists in managing lists and collections of objects, such as carts, wishlists, or compare lists, in CoreShop.

Installation Process

To install the Storage List Bundle, use Composer:

$ composer require coreshop/storage-list-bundle:^4.0


The bundle requires three models to function effectively:

  1. Storage List - Represents the collection. Implement the StorageListInterface.
  2. Storage Item - The item within the collection, which can store additional information, such as prices for a cart. Implement the StorageListItemInterface.
  3. Storage Product - The actual product being stored inside the item. Implement the StorageListProductInterface.

CoreShop provides basic implementations of Storage List and Storage Item. You will need to implement the StorageListProduct yourself.

Mutating Lists

Use the Storage List Modifier to create and persist lists.

Example: Basic Session-Based Wishlist

Let's create a session-based wishlist with the following components:

  • Factory class for the Wishlist
  • Factory class for the Wishlist Item
  • StorageListManager (repository-like)
  • StoreListModifier

CoreShop provides basic classes for these components:

use Symfony\Component\HttpFoundation\Session\Session;

use CoreShop\Component\StorageList\Model\StorageList;
use CoreShop\Component\StorageList\Model\StorageListItem;
use CoreShop\Component\Resource\Factory\Factory;
use CoreShop\Component\StorageList\SessionStorageManager;
use CoreShop\Component\StorageList\SessionStorageListModifier;

$session = new Session();

$wishlistFactory = new Factory(StorageList::class);
$wishlistItemFactory = new Factory(StorageListItem::class);

$wishlistManager = new SessionStorageManager($session, 'wishlist', $wishlistFactory);
$wishlistModifier = new SessionStorageListModifier($wishlistItemFactory, $wishlistManager);

// Adding data to our List
$list = $wishlistManager->getStorageList();
$product = $productRepository->find(1); // Assumes StorageListProductInterface implementation

$listItem = $wishlistItemFactory->createNew();

// Adding a Product
$wishlistModifier->addToList($list, $listItem);

// Removing a Product
$wishlistModifier->removeFromList($list, $listItem);

This bundle simplifies the management of various storage lists within CoreShop, enhancing the functionality and user experience of your e-commerce platform.