Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Oro Show Orders By Shopping List Laravel Package

25carat/oro-show-orders-by-shopping-list

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require 25carat/oro-show-orders-by-shopping-list
    php bin/console oro:platform:update --force
    
  2. Clear Cache

    php bin/console cache:clear
    
  3. First Use Case

    • Navigate to My Account > Order History in the frontend.
    • Verify the new "Shopping List" column appears in the order grid.
    • Test filtering by shopping list name to confirm functionality.

Implementation Patterns

Core Workflow

  1. Frontend Integration

    • The bundle extends OroCommerce’s default order grid via Twig templates (templates/orocommerce/account/order/index.html.twig).
    • Override the template in your theme to customize column visibility or labels:
      {% extends 'OroShowOrdersByShoppingList::account/order/index.html.twig' %}
      {% block oro_account_order_grid_columns %}
          {{ parent() }}
          {# Customize column order or visibility #}
      {% endblock %}
      
  2. Data Binding

    • The bundle hooks into Oro’s order repository to fetch linked shopping lists.
    • Extend the Oro\Bundle\OrderBundle\Entity\Order entity if you need custom logic:
      // src/Entity/Order.php
      public function getShoppingList()
      {
          return $this->getShoppingList(); // Default method provided by the bundle
      }
      
  3. Filtering

    • The bundle adds a shopping list filter to the grid.
    • Customize filter behavior by extending the grid’s datagrid configuration:
      # config/oro/datagrids/order.yaml
      OroShowOrdersByShoppingList:
          columns:
              shopping_list:
                  label: 'Shopping List'
                  type: 'shopping_list' # Custom type (provided by the bundle)
          filters:
              shopping_list:
                  type: 'shopping_list' # Custom filter (provided by the bundle)
      
  4. API/Backend Usage

    • Use the bundle’s query builder extensions to fetch orders by shopping list in backend services:
      use Oro\Bundle\ShowOrdersByShoppingListBundle\Query\OrderQueryBuilderExtension;
      
      $qb = $entityManager->getRepository(Order::class)->createQueryBuilder('o');
      $qb->getEntityManager()->getFilters()->disable('non_loaded_metadata_collection');
      $extension = new OrderQueryBuilderExtension($qb);
      $extension->addShoppingListFilter('list_name');
      

Gotchas and Tips

Pitfalls

  1. Shopping List Deletion Blocked

    • The bundle disables shopping list deletion to preserve order links.
    • Workaround: If you need deletion, override the deleteAction in your controller:
      // src/Acme/ShoppingListBundle/Controller/ShoppingListController.php
      public function deleteAction(Request $request, $id)
      {
          // Custom logic to allow deletion (e.g., check for linked orders)
          return $this->forwardToRoute('oro_shoppinglist_delete', ['id' => $id]);
      }
      
  2. Template Overrides

    • If the grid doesn’t render, ensure your theme’s base.html.twig includes the bundle’s assets:
      {{ parent() }}
      {% block stylesheets %}
          {{ parent() }}
          <link rel="stylesheet" href="{{ asset('bundles/oroshoppinglist/css/order-grid.css') }}">
      {% endblock %}
      
  3. Performance with Large Datasets

    • The bundle adds a JOIN to the shopping_list table in queries.
    • Optimization: Add an index to the shopping_list_order table if queries are slow:
      CREATE INDEX idx_shopping_list_order ON shopping_list_order (shopping_list_id, order_id);
      
  4. Localization Issues

    • Column labels/filter placeholders may not translate if your theme lacks Oro’s translation files.
    • Fix: Extend the bundle’s translation files:
      # config/oro/translations/messages.en.yml
      OroShowOrdersByShoppingList:
          ShoppingList: 'Shopping List'
          Filter by Shopping List: 'Filter by Shopping List'
      

Debugging Tips

  1. Check Grid Configuration

    • Dump the datagrid configuration to verify the column/filter is loaded:
      $gridName = 'oro_account_order';
      $gridConfig = $this->container->get('oro_datagrid.datagrid.registry')->getDatagrid($gridName)->getConfiguration();
      dump($gridConfig);
      
  2. Query Logging

    • Enable Doctrine query logging to inspect SQL:
      // config/packages/dev/doctrine.yaml
      doctrine:
          dbal:
              logging: true
              profiling: true
      
  3. Event Listeners

    • The bundle may dispatch events (e.g., oro_shopping_list.post_delete). Listen for them to debug:
      // src/EventListener/ShoppingListListener.php
      public function onPostDelete(ShoppingListEvent $event)
      {
          if (!$event->getShoppingList()->getOrders()->isEmpty()) {
              throw new \RuntimeException('Cannot delete shopping list with orders.');
          }
      }
      

Extension Points

  1. Customize Column Data

    • Extend the Oro\Bundle\ShowOrdersByShoppingListBundle\Provider\OrderShoppingListProvider to modify how shopping lists are fetched for orders:
      // src/Provider/CustomOrderShoppingListProvider.php
      public function getShoppingList(Order $order)
      {
          // Custom logic (e.g., fallback to a default list)
          return $order->getShoppingList() ?: $this->findDefaultList();
      }
      
  2. Add Batch Actions

    • Use Oro’s datagrid batch actions to add bulk operations (e.g., "Reorder from Shopping List"):
      # config/oro/datagrids/order.yaml
      OroShowOrdersByShoppingList:
          actions:
              reorder:
                  type: 'reorder'
                  label: 'Reorder from Shopping List'
                  acl: 'oro_order_reorder'
      
  3. API Endpoint

    • Expose shopping list data via API by extending the Oro\Bundle\OrderBundle\Api\OrderApi:
      // src/Api/OrderApiExtension.php
      public function getAdditionalData(Order $order, array $context = [])
      {
          return [
              'shopping_list' => $order->getShoppingList() ? $order->getShoppingList()->getName() : null,
          ];
      }
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui