Basket is empty after redirect
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Basket is empty after redirect
I create basket controller object
and add product to basket
Right after adding before redirecting when I execute the method
I receive
But after redirect to another page products are empty
I had earlier in .env
SESSION_DRIVER=database
and change to
SESSION_DRIVER=file
Problem still ocurring.
I think maybe problem in my extends => Aimeos\MShop\Order\Item\CustomOrderItem (in attachment is Manager and Item code in zip file)
My redirect code is
"aimeos_shop_checkout" is custom controller in Laravel
I done test and before redirect was added
And in new page
And it showed me this value
It follows that the session itself in Laravel works correctly, only something with the Aimeos basket session
My Aimeos version
"aimeos/aimeos-laravel": "^2024.10",
Laravel framework
"laravel/framework": "^10.0",
Code: Select all
$basketCntl = \Aimeos\Controller\Frontend::create($context, 'basket');
Code: Select all
$basketCntl->addProduct
Code: Select all
dd($basketCntl->get())
Code: Select all
Aimeos\MShop\Order\Item\CustomOrderItem {#1220 ▼ // app\Http\Controllers\AimeosBasketController.php:68
#available: true
#modified: true
#bprefix: "order."
#type: null
#bdata: array:3 [▶]
#customer: null
#locale:
Aimeos\MShop\Locale\Item
\
Standard {#920 ▶}
#price:
Aimeos\MShop\Price\Item
\
Standard {#1012 ▶}
#recalc: true
#coupons: []
#products: array:1 [▼
0 =>
Aimeos\MShop\Order\Item\Product
\
Standard {#1381 ▼
#available: true
#modified: true
#bprefix: "order.product."
#type: null
#bdata: array:14 [▼
".price" =>
Aimeos\MShop\Price\Item
\
Standard {#1416 ▶}
"order.product.siteid" => "1."
"order.product.prodcode" => "2230047623841"
"order.product.productid" => "6"
"order.product.type" => "e-card"
"order.product.scale" => 1.0
"order.product.target" => ""
"order.product.name" => "Wirtualna Karta Podarunkowa CCC x HalfPrice"
"order.product.mediaurl" => "cards/151.jpg?v=20250126182007"
"order.product.quantity" => 1.0
"order.product.stocktype" => "default"
".attributes" =>
Aimeos
\
Map {#1074 ▶}
"order.product.vendor" => "pl"
"order.product.timeframe" => ""
]
-attributesMap: array:1 [▼
"custom" => array:2 [▼
"price" => array:1 [▶]
"text" => array:1 [▶]
]
]
}
]
#services: []
#statuses: []
#addresses: []
#listeners: array:13 [▶]
}
Code: Select all
Aimeos\MShop\Order\Item\CustomOrderItem {#896 ▼ // app\Http\Controllers\AimeosCheckoutController.php:38
#available: true
#modified: false
#bprefix: "order."
#type: null
#bdata: array:3 [▶]
#customer: null
#locale:
Aimeos\MShop\Locale\Item
\
Standard {#945 ▼
#available: true
#modified: false
#bprefix: "locale."
#type: null
#bdata: array:10 [▶]
-siteItem:
Aimeos\MShop\Locale\Item\Site
\
Standard {#920 ▼
#available: true
#modified: false
#bprefix: "locale.site."
#type: null
#bdata: array:18 [▶]
}
-sites: array:1 [▶]
}
#price:
Aimeos\MShop\Price\Item
\
Standard {#892 ▶}
#recalc: false
#coupons: []
#products: []
#services: []
#statuses: []
#addresses: []
#listeners: array:12 [▼
"addAddress.after" => array:2 [▶]
"deleteAddress.after" => array:2 [▶]
"setAddresses.after" => array:2 [▶]
"addCoupon.after" => array:2 [▶]
"deleteCoupon.after" => array:2 [▶]
"addProduct.after" => array:2 [▶]
"deleteProduct.after" => array:2 [▶]
"setProducts.after" => array:2 [▶]
"addService.after" => array:1 [▶]
"deleteService.after" => array:1 [▶]
"setServices.after" => array:1 [▶]
"setOrder.before" => array:1 [▶]
]
}
SESSION_DRIVER=database
and change to
SESSION_DRIVER=file
Problem still ocurring.
I think maybe problem in my extends => Aimeos\MShop\Order\Item\CustomOrderItem (in attachment is Manager and Item code in zip file)
My redirect code is
Code: Select all
return redirect()->route('aimeos_shop_checkout', ['site' => $site, 'c_step' => 'onepage']);
I done test and before redirect was added
Code: Select all
session()->put('test', '123')
Code: Select all
dd(session()->all());
It follows that the session itself in Laravel works correctly, only something with the Aimeos basket session
My Aimeos version
"aimeos/aimeos-laravel": "^2024.10",
Laravel framework
"laravel/framework": "^10.0",
- Attachments
-
- Order.zip
- (1.59 KiB) Downloaded 2817 times
Re: Basket is empty after redirect
You need to call save() to persist the basket:
https://github.com/aimeos/ai-controller ... hp#L45-L50
https://github.com/aimeos/ai-controller ... hp#L45-L50
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

Re: Basket is empty after redirect
The basket is still empty.
Code before redirect:
Before redirect:
https://prnt.sc/cTzco3ibCS2R
After redirect:
https://prnt.sc/ZJnEzfl6vV_y
Code after redirect on another page:
In addProduct method is already exists "save" method
https://github.com/aimeos/ai-controller ... L333-#L363
I also tried to call "save" a second time but it didn't help
Code before redirect:
Code: Select all
$context = app('aimeos.context').get(true);
$basketCntl = \Aimeos\Controller\Frontend::create($context, 'basket');
$basketCntl->addProduct(
$productCntl->get($values['prodid']),
(float) ($values['quantity'] ?? 0),
array_filter((array) ($values['attrvarid'] ?? [])),
$this->getAttributeMap((array) ($values['attrconfid'] ?? [])),
array_filter((array) ($values['attrcustid'] ?? [])),
(string) ($values['stocktype'] ?? 'default'),
//(string) ($values['supplier'] ?? ''),
$values['siteid'] ?? null
);
return redirect()->route('aimeos_shop_checkout', ['site' => $site, 'c_step' => 'onepage']);
https://prnt.sc/cTzco3ibCS2R
After redirect:
https://prnt.sc/ZJnEzfl6vV_y
Code after redirect on another page:
Code: Select all
$context = app('aimeos.context').get(true);
$basketCntl = \Aimeos\Controller\Frontend::create($context, 'basket');
dd($basketCntl->get());
https://github.com/aimeos/ai-controller ... L333-#L363
I also tried to call "save" a second time but it didn't help
Re: Basket is empty after redirect
At this point I even disconnected my extensions and the cart is still empty.
I noticed that in the save() method, before saving to the session, the products are
https://prnt.sc/cdyi9lRn4zWk
However, in the setSession method in trait Session products is already empty
https://prnt.sc/G-Hf6Ymb87Ee
I use WampServer, PHP 8.2
My composer.json
I noticed that in the save() method, before saving to the session, the products are
https://prnt.sc/cdyi9lRn4zWk
However, in the setSession method in trait Session products is already empty
https://prnt.sc/G-Hf6Ymb87Ee
I use WampServer, PHP 8.2
My composer.json
Code: Select all
{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": [
"framework",
"laravel"
],
"license": "MIT",
"require": {
"php": "^8.2",
"aimeos-extensions/new-ext": "dev-main",
"aimeos/aimeos-laravel": "^2024.10",
"azuyalabs/yasumi": "^2.7",
"barryvdh/laravel-snappy": "^1.0",
"jschaedl/iban-validation": "^2.5",
"laravel/framework": "^10.0",
"laravel/jetstream": "^4.3",
"phpoffice/phpspreadsheet": "^3.9",
"picqer/php-barcode-generator": "^2.4",
"rootinc/laravel-azure-middleware": "^0.9.10",
"spatie/laravel-backup": "^8.8",
"spatie/laravel-permission": "^6.10",
"symfony/http-client": "^6.4",
"symfony/mailgun-mailer": "^6.4"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.2",
"nunomaduro/collision": "^7.0",
"phpunit/phpunit": "^10.0",
"spatie/laravel-ignition": "^2.0"
},
"autoload": {
"psr-4": {
"App\\": "app/",
"Database\\Factories\\": "database/factories/",
"Database\\Seeders\\": "database/seeders/"
},
"files": [
"app/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi"
]
},
"repositories": [
{
"type": "composer",
"url": "https://packages.aimeos.org/aimeoscom"
},
{
"type": "path",
"url": "./packages/*",
"options": {
"symlink": false
}
}
],
"extra": {
"laravel": {
"dont-discover": []
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
Re: Basket is empty after redirect
I resolved my problem
. I used app('aimeos.context').get() in constructor of controller and I move it to action controller.
