mar-pod / module-bulk-add-to-cart
Bulk AJAX product addition to the Magento 2 shopping cart with a detailed per-item report.
Package info
gitlab.com/mar-pod/module-bulk-add-to-cart
Type:magento2-module
pkg:composer/mar-pod/module-bulk-add-to-cart
Requires
- php: ^8.5
- magento/framework: ^103.0
- magento/module-catalog: ^104.0
- magento/module-checkout: ^100.4
- magento/module-config: ^101.2
- magento/module-quote: ^101.2
- mar-pod/module-core: ^2.0.0
This package is auto-updated.
Last update: 2026-08-14 18:01:47 UTC
README
Magento 2 module that uploads up to 500 SKU/quantity rows from CSV to the shopping cart with one AJAX request and a detailed per-item report.
Features
- link from both full and empty shopping-cart pages;
- CSV file browser with a visible product preview before submission;
- client-side and server-side extension, size, header, and row validation;
- downloadable example CSV file on the bulk-add page;
- support for guest and signed-in customer carts;
- one quote save per request for efficient large imports;
- success or failure status and an explanatory message for every submitted row;
- automatic refresh of Magento's private cart customer-data section;
- direct button from the bulk form to the shopping cart.
Products that require additional configuration, such as configurable or bundle products, are rejected with Magento's validation message. The first release intentionally accepts only SKU and quantity and does not guess product options.
Requirements
- PHP 8.5
- Magento Open Source or Adobe Commerce 2.4.9
- Magento Catalog, Checkout, Config, and Quote modules
Installation
composer require mar-pod/module-bulk-add-to-cart:^2.0
bin/magento module:enable Marpod_BulkAddToCart
bin/magento setup:upgrade
bin/magento setup:di:compile
bin/magento cache:clean
The maximum upload size is configured under Stores > Configuration > Marpod > Marpod Configuration > Bulk Add to Cart. The default and minimum value is 1 MB. Website and store-view scopes are supported.
All source strings and developer-facing documentation are maintained in English. Translations, when needed by a consuming project, should be supplied outside this package.
Usage
Open the shopping cart and select Add multiple products, or visit:
/bulk-add-to-cart
Upload a CSV file with this structure:
sku,qty
24-MB01,2
24-MB02,5
24-MB03,1
An example CSV file can be downloaded directly above the file browser. Comma, semicolon, and tab delimiters are accepted.
The module processes at most 500 rows per request. Invalid SKU values, non-positive quantities, unavailable products, insufficient stock, and products requiring options remain visible in the final report with their Magento validation reason.
AJAX endpoint
The storefront form posts a valid Magento form key and a multipart csv_file upload to:
POST /bulk-add-to-cart/cart/add
The endpoint is intended for same-origin storefront use and is protected by Magento's standard form-key validation.
Testing
The repository contains unit tests, Magento integration tests, and Playwright storefront tests.
Run unit tests from the Magento root when installed as a path repository:
vendor/bin/phpunit -c dev/tests/unit/phpunit.xml.dist \
packages/module-bulk-add-to-cart/Test/Unit
For a regular Composer installation, use vendor/mar-pod/module-bulk-add-to-cart/Test/Unit as the test path.
Run the integration test with Magento's integration-test configuration:
vendor/bin/phpunit -c dev/tests/integration/phpunit.xml.dist \
/absolute/path/to/module-bulk-add-to-cart/Test/Integration
Run Playwright tests:
cd packages/module-bulk-add-to-cart/Test/Playwright
npm install
npx playwright install chromium
npm test
Set PLAYWRIGHT_BASE_URL when Magento is not available at http://localhost:8090.
Extension points
Magento's native ProductRepositoryInterface and checkout Cart model perform product loading, option validation, stock validation, and quote updates. Projects can customize standard Magento product/cart behavior without replacing this module.