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

Pim Community Dev Laravel Package

akeneo/pim-community-dev

Deep Wiki
Context7

Getting Started

Minimal Setup for Local Development

  1. Clone the Repository

    git clone https://github.com/akeneo/pim-community-dev.git
    cd pim-community-dev
    
    • Use the dev-master branch for the latest development version.
  2. Install Dependencies

    composer install
    
    • Ensure composer.json has the correct Akeneo PIM version constraints (e.g., ^3.2 or ^4.0).
  3. Configure Environment

    • Copy .env.dist to .env and update:
      APP_ENV=dev
      APP_DEBUG=true
      DATABASE_URL="mysql://user:pass@127.0.0.1:3306/pim"
      
    • Generate app key:
      php bin/console akeneo:install:framework
      
  4. First Use Case: Launch a Local PIM Instance

    php bin/console server:run
    
    • Access the PIM at http://localhost:8000 (admin credentials: admin/admin).

Where to Look First

  • Documentation: Akeneo PIM Community Docs (official, but may lag behind dev branch).
  • Core Directories:
    • src/ – Core PIM logic (models, services, controllers).
    • config/ – Bundle configurations (e.g., pim_catalog, pim_enrich).
    • var/ – Runtime data (logs, cache, uploads).
  • Debugging Tools:
    • php bin/console debug:config – Inspect loaded configurations.
    • php bin/console debug:container – Browse service container.

Implementation Patterns

1. Extending Catalog Structure

Use Case: Adding custom attributes or attribute types.

  • Pattern: Create a custom bundle and override PIM’s attribute system.
    # config/pim_catalog/attributes.yaml
    akeneo_attribute.simple:
        pim_catalog.attribute.simple:
            - your_custom_attribute
    
  • Workflow:
    1. Define a new attribute in config/pim_catalog/attributes.yaml.
    2. Create a service to handle custom logic (e.g., validation):
      // src/Service/CustomAttributeValidator.php
      class CustomAttributeValidator implements AttributeValidatorInterface
      {
          public function validate($value, AttributeInterface $attribute) { ... }
      }
      
    3. Register the service in services.yaml:
      services:
          your_bundle.validator.custom:
              class: Your\Bundle\Service\CustomAttributeValidator
              tags: [pim_catalog.attribute_validator]
      

2. Customizing Enrichment UI

Use Case: Adding a tab or modifying the product grid.

  • Pattern: Use PIM’s Twig templates and JavaScript events.
    {# templates/pim_enrich/product/_tab_custom.html.twig #}
    <div class="custom-tab">
        {{ include('YourBundle:Product:_custom_content.html.twig') }}
    </div>
    
  • Integration Tips:
    • Extend the grid via pim_enrich.grid events (Symfony EventDispatcher).
    • Use pim_enrich.datagrid.builder to modify columns:
      $builder->add('your_custom_column', 'string', [
          'label' => 'Your Label',
          'searchable' => true,
      ]);
      

3. API Extensions

Use Case: Adding endpoints or modifying API responses.

  • Pattern: Use FOSRestBundle or override PIM’s API controllers.
    # config/routes/your_api.yaml
    your_api_product:
        path: /api/product/custom
        methods: [GET]
        defaults:
            _controller: your_bundle.controller.product::customAction
            _format: json
    
  • Workflow:
    1. Create a controller extending Pim\Bundle\CatalogBundle\Controller\Api\Rest\ProductController.
    2. Override methods like getProduct() to inject custom logic.
    3. Secure endpoints with PIM’s API authentication (e.g., pim_user.api_token).

4. Workflow Automation

Use Case: Triggering actions on product updates.

  • Pattern: Use PIM’s event system.
    // src/EventListener/ProductUpdateListener.php
    class ProductUpdateListener implements EventSubscriberInterface
    {
        public static function getSubscribedEvents()
        {
            return [
                'pim_catalog.product.update' => 'onProductUpdate',
            ];
        }
    
        public function onProductUpdate(ProductUpdateEvent $event) { ... }
    }
    
  • Integration Tips:
    • Listen to events like pim_catalog.product.create, pim_catalog.attribute.update.
    • Use ProductManagerInterface to fetch/update products in listeners.

Gotchas and Tips

Pitfalls

  1. Database Migrations

    • PIM uses Doctrine migrations (src/Akeneo/Pim/InstallerBundle/Resources/migrations).
    • Gotcha: Running php bin/console doctrine:migrations:migrate may fail if schema is out of sync. Use:
      php bin/console pim:installer:database:load --env=dev
      
    • Tip: Always back up var/data before migrations.
  2. Caching Quirks

    • PIM uses Symfony’s cache system aggressively.
    • Gotcha: Clear cache after config changes:
      php bin/console cache:clear
      php bin/console pim:installer:assets:install
      
    • Tip: Use APP_DEBUG=true to bypass cache during development.
  3. Attribute Types

    • Gotcha: Custom attribute types must implement Akeneo\Tool\Component\Attribute\Type\TypeInterface.
    • Tip: Extend existing types (e.g., pim_catalog.attribute.type.simple) instead of reinventing.
  4. Symfony Flex Conflicts

    • Gotcha: akeneo/pim-community-dev may conflict with Symfony Flex recipes.
    • Tip: Disable Flex for PIM bundles:
      composer config extra.symfony.allow-contrib true
      

Debugging Tips

  1. Log Configuration

    • Enable debug logging in .env:
      MONOLOG_LEVEL=debug
      
    • Check logs at var/log/dev.log.
  2. Dumping Data

    • Use Symfony’s var dumper:
      dump($product->getValues());
      
    • For API responses, use:
      php bin/console debug:container | grep serializer
      
  3. Common Errors

    • "Class not found": Ensure bundles are enabled in config/bundles.php.
    • Missing translations: Run:
      php bin/console pim:installer:assets:install --env=dev
      

Extension Points

  1. Custom Bundles

    • Place bundles in src/ or vendor/ (for reusable packages).
    • Example structure:
      src/
      ├── Your/
      │   └── Bundle/
      │       ├── DependencyInjection/
      │       ├── Resources/
      │       │   └── config/
      │       │       └── services.yaml
      │       └── YourBundle.php
      
  2. Hooking into PIM’s Pipeline

    • Use pim_catalog.pre_save_product or pim_catalog.post_save_product events.
    • Example:
      # config/services.yaml
      services:
          your_bundle.listener.product_hook:
              class: Your\Bundle\EventListener\ProductHookListener
              tags:
                  - { name: kernel.event_listener, event: pim_catalog.pre_save_product, method: onPreSave }
      
  3. Overriding Templates

    • Copy templates from vendor/akeneo/pim-community-dev/src/Pim/Bundle/*Bundle/Resources/views/ to templates/pim/*bundle/*/ in your project.
    • Example override:
      templates/
      └── pim_enrich/
          └── product/
              └── _form.html.twig
      
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware