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

Akeneo Inline Edit Bundle Laravel Package

default-value/akeneo-inline-edit-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require default-value/akeneo-inline-edit-bundle:2.0
    

    Add the bundle to AppKernel.php and include its routing in routing.yml.

  2. First Use Case: Enable inline editing for a specific Akeneo PIM product grid by configuring the datagrid YAML. Start with a simple attribute (e.g., sku or enabled) to test functionality.

    Example minimal datagrid.yml snippet:

    properties:
        sku:
            type: text
            editable: true
        enabled:
            type: boolean
            editable: true
    
  3. Where to Look First:

    • Check DefaultValueAkeneoInlineEditBundle/Resources/config/routing.yml for route definitions.
    • Review DefaultValueAkeneoInlineEditBundle/Resources/views/ for Twig templates (e.g., edit.html.twig).
    • Inspect DefaultValueAkeneoInlineEditBundle/DependencyInjection/ for configuration schema.

Implementation Patterns

Workflows

  1. Configuring Editable Attributes:

    • Define editable: true in the properties section of your datagrid.yml for each attribute you want to edit inline.
    • Example:
      properties:
          name:
              type: text
              editable: true
              label: "Product Name"
          price:
              type: price
              editable: true
              label: "Base Price"
      
  2. Handling Updates:

    • The bundle provides a route (default_value_inline_edit_update_attribute) to handle AJAX updates. Override or extend the controller (DefaultValue\Bundle\AkeneoInlineEditBundle\Controller\InlineEditController) if custom logic is needed.
    • Example route params in datagrid.yml:
      update_attribute_value:
          type: url
          route: default_value_inline_edit_update_attribute
          params:
              _route_params:
                  attribute_code: "sku"
      
  3. Integration with Akeneo Events:

    • Listen to Akeneo’s pim_enrich.datagrid.product.action.edit.pre or pim_enrich.datagrid.product.action.edit.post events to customize behavior before/after inline edits.
    • Example service:
      // src/Akeneo/EventListener/InlineEditListener.php
      public function onInlineEditPre(InlineEditEvent $event) {
          $product = $event->getProduct();
          if (!$product->isEnabled()) {
              $event->setAllowed(false); // Disable edit for disabled products
          }
      }
      
  4. Custom Templates:

    • Override Twig templates (e.g., edit.html.twig) in your theme to customize the inline edit UI. Place them in:
      app/Resources/DefaultValueAkeneoInlineEditBundle/views/
      
  5. Validation:

    • Extend the bundle’s validation logic by overriding the InlineEditValidator service or adding custom constraints to the edited attributes.

Gotchas and Tips

Pitfalls

  1. Routing Conflicts:

    • Ensure the bundle’s routes (default_value_akeneo_inline_edit) don’t conflict with existing routes. Use _route_params in datagrid.yml to disambiguate:
      update_attribute_value:
          params:
              _route_params:
                  attribute_code: "custom_sku"
      
  2. Caching Issues:

    • Clear Akeneo’s cache (php bin/console pim:cache:clear) after enabling the bundle or modifying configurations. Inline edits may not reflect changes otherwise.
  3. Attribute-Specific Quirks:

    • Some Akeneo attribute types (e.g., pim_catalog_identifier, pim_catalog_textarea) may require additional JavaScript or template overrides to render correctly in inline mode.
    • Test with type: price, type: date, and type: boolean attributes first—they often have edge cases.
  4. Permission Handling:

    • The bundle inherits Akeneo’s permission system. Ensure users have EDIT_PRODUCT permissions for the attributes they’re editing inline. Add custom checks in event listeners if needed.
  5. JavaScript Dependencies:

    • The bundle relies on Akeneo’s existing frontend assets (e.g., pim-enrich). If you’re using a custom frontend (e.g., React/Vue), you’ll need to manually integrate the inline edit logic via AJAX calls to the bundle’s routes.

Debugging

  1. Check AJAX Responses:

    • Use browser dev tools to inspect failed inline edits. Common issues:
      • 403 Forbidden: Missing permissions or invalid CSRF token.
      • 500 Internal Server Error: Validation failures or missing data in the request.
    • Enable debug mode (APP_DEBUG=true) and check var/log/dev.log for errors.
  2. Log Events:

    • Add debug logs in event listeners to trace the flow:
      public function onInlineEditPost(InlineEditEvent $event) {
          $this->logger->debug('Inline edit triggered for product ID: ' . $event->getProduct()->getId());
      }
      
  3. Validate Configuration:

    • Use php bin/console debug:config default_value_akeneo_inline_edit to verify your datagrid.yml is loaded correctly.

Tips

  1. Batch Editing:

    • Extend the bundle to support bulk inline edits by modifying the InlineEditController to accept arrays of product IDs and attributes.
  2. Undo/Redo:

    • Implement a history feature by storing old values in the pim_catalog_value table before updates and adding a "revert" option to the inline edit UI.
  3. Performance:

    • For large grids, lazy-load editable attributes using AJAX to avoid bloating the initial page load. Example:
      // Custom JS to load editable fields on demand
      $(document).on('click', '.inline-edit-trigger', function() {
          const attributeCode = $(this).data('attribute');
          $.get(`/inline-edit/load-field?attribute=${attributeCode}`, function(html) {
              $(this).replaceWith(html);
          });
      });
      
  4. Localization:

    • Override translation files (translations/messages.en.xlf) to customize labels for inline edit buttons (e.g., "Save", "Cancel").
  5. Testing:

    • Write functional tests for inline edits using Akeneo’s WebTestCase:
      public function testInlineEdit() {
          $client = static::createClient();
          $client->request('GET', '/pim/enrich/product');
          $client->submitForm('Edit SKU', [], ['sku' => 'NEW_SKU']);
          $this->assertPageContains('NEW_SKU');
      }
      
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.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime