Skip to content

Commit

Permalink
AddToCartAction - fixed load bulk load of structured data
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Jan 20, 2016
1 parent a353ba1 commit a5b966e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/actions/AddToCartAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,14 @@ public function run()
$collection = new Collection(); // TODO: drop dependency
$collection->setModel($model);

if ($this->bulkLoad) {
$data = [];
$selection = $request->post('selection');
foreach ($selection as $id) {
$data[$id] = [reset($model->primaryKey()) => $id];
}
} else {
if (!$this->bulkLoad) {
$data = [$request->post() ?: $request->get()];
$collection->load($data);
} else {
$collection->load();
}

if ($collection->load($data) && $collection->validate()) {
if ($collection->validate()) {
foreach ($collection->models as $position) {
/** @var CartPositionInterface $position */
if (!$cart->hasPosition($position->getId())) {
Expand Down

0 comments on commit a5b966e

Please sign in to comment.