Skip to content

Dead (?) code in ShoppingListBundle/Form/Handler/LineItemHandler #135

Open
@jankulma-turbine

Description

@jankulma-turbine

Summary
In LineItemHandler there is a part where case for new ShoppingList creation is seemingly covered, but it's never called, and looks like dead code to me:

https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/ShoppingListBundle/Form/Handler/LineItemHandler.php#L82-L89

        // handle case for new shopping list creation
        $formName = $this->form->getName();
        $formData = $this->request->request->get($formName, []);
        if (empty($formData['shoppingList']) && !empty($formData['shoppingListLabel'])) {
            $shoppingList = $this->currentShoppingListManager->createCurrent($formData['shoppingListLabel']);
            $formData['shoppingList'] = $shoppingList->getId();
            $this->request->request->set($formName, $formData);
        }

This handler is called only in

  1. \Oro\Bundle\ShoppingListBundle\Controller\Frontend\AjaxLineItemController::addProductFromViewAction where ShoppingList is always created before, if it didn't exist:
    https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/ShoppingListBundle/Controller/Frontend/AjaxLineItemController.php#L59
$shoppingList = $currentShoppingListManager->getForCurrentUser($request->get('shoppingListId'));

https://github.com/oroinc/orocommerce/blob/master/src/Oro/Bundle/ShoppingListBundle/Controller/Frontend/Api/Rest/LineItemController.php#L144
\Oro\Bundle\ShoppingListBundle\Controller\Frontend\Api\Rest\LineItemController::putAction
which is responsible for updating a LineItem, so it must be assigned to a ShoppingList already.

JK

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions