default-value/akeneo-inline-edit-bundle
Installation:
composer require default-value/akeneo-inline-edit-bundle:2.0
Add the bundle to AppKernel.php and include its routing in routing.yml.
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
Where to Look First:
DefaultValueAkeneoInlineEditBundle/Resources/config/routing.yml for route definitions.DefaultValueAkeneoInlineEditBundle/Resources/views/ for Twig templates (e.g., edit.html.twig).DefaultValueAkeneoInlineEditBundle/DependencyInjection/ for configuration schema.Configuring Editable Attributes:
editable: true in the properties section of your datagrid.yml for each attribute you want to edit inline.properties:
name:
type: text
editable: true
label: "Product Name"
price:
type: price
editable: true
label: "Base Price"
Handling Updates:
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.datagrid.yml:
update_attribute_value:
type: url
route: default_value_inline_edit_update_attribute
params:
_route_params:
attribute_code: "sku"
Integration with Akeneo Events:
pim_enrich.datagrid.product.action.edit.pre or pim_enrich.datagrid.product.action.edit.post events to customize behavior before/after inline edits.// src/Akeneo/EventListener/InlineEditListener.php
public function onInlineEditPre(InlineEditEvent $event) {
$product = $event->getProduct();
if (!$product->isEnabled()) {
$event->setAllowed(false); // Disable edit for disabled products
}
}
Custom Templates:
edit.html.twig) in your theme to customize the inline edit UI. Place them in:
app/Resources/DefaultValueAkeneoInlineEditBundle/views/
Validation:
InlineEditValidator service or adding custom constraints to the edited attributes.Routing Conflicts:
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"
Caching Issues:
php bin/console pim:cache:clear) after enabling the bundle or modifying configurations. Inline edits may not reflect changes otherwise.Attribute-Specific Quirks:
pim_catalog_identifier, pim_catalog_textarea) may require additional JavaScript or template overrides to render correctly in inline mode.type: price, type: date, and type: boolean attributes first—they often have edge cases.Permission Handling:
EDIT_PRODUCT permissions for the attributes they’re editing inline. Add custom checks in event listeners if needed.JavaScript Dependencies:
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.Check AJAX Responses:
APP_DEBUG=true) and check var/log/dev.log for errors.Log Events:
public function onInlineEditPost(InlineEditEvent $event) {
$this->logger->debug('Inline edit triggered for product ID: ' . $event->getProduct()->getId());
}
Validate Configuration:
php bin/console debug:config default_value_akeneo_inline_edit to verify your datagrid.yml is loaded correctly.Batch Editing:
InlineEditController to accept arrays of product IDs and attributes.Undo/Redo:
pim_catalog_value table before updates and adding a "revert" option to the inline edit UI.Performance:
// 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);
});
});
Localization:
translations/messages.en.xlf) to customize labels for inline edit buttons (e.g., "Save", "Cancel").Testing:
WebTestCase:
public function testInlineEdit() {
$client = static::createClient();
$client->request('GET', '/pim/enrich/product');
$client->submitForm('Edit SKU', [], ['sku' => 'NEW_SKU']);
$this->assertPageContains('NEW_SKU');
}
How can I help you explore Laravel packages today?