Git Product home page Git Product logo

feedbuilderbundle's Introduction

FeedBuilderBundle

Feedbuilder bundle is export bundle that helps to export data of pimcore to other systems.

Installation

The installation can be installed though composer.

  1. Run composer require jorisros/feed-builder-bundle to receive the bundle
  2. Enable the bundle bin/console pimcore:bundle:enable FeedBuilderBundle and then run ./bin/console pimcore:bundle:enable OutputDataConfigToolkitBundle because you need to have both enabled.
  3. Then reload the GUI of Pimcore, and there is a new menu item on the following location: Settings->Settings feedbuilder, this interface saves the in a configuration file on the following location var/config/feedbuilder.php

How does it works?

The working is quite simple, you discibe your export method to the level you want, that's give you data you want. This is based on the output channel bundle

Events

We can easily extend the feedbuilder to fit your own situation. The following event handlers are inside the builder to you can subscribe to events on different levels of the building of the feeds.

Event Description
feedbuilder.before.run This event is triggered as first event, the input of this event is the configuration of the feeed.
feedbuilder.after.selection The event after the selection has been runned, this input for this event is the object listener. This is desgined for customize the query
feedbuilder.before.row This is the event before the object is converted to array, the input of this event is a object
feedbuilder.after.row The event after the object is converted from a object to a array. The input of this event is a array
feedbuilder.after.run Latest step of building the feed, this is triggered after looping through the objects. The input of the event is de result in a array.

Flow of the builder

Ignore cache in your feed

It is possible to ignore the cache in your feed while developing or testing. You can give the run method in the composer a second boolean parameter, so it clears the cache before it runs the query code. In the browser you can add the following get parameter to the feed: ...name-of-json.json?ignoreCache=true then the cache will be cleared before you run the feedbuilder.

Example of a export to JSON

Create a class and a method where the writer is been located.

<?php

namespace FeedBuilderBundle\EventListener;

use FeedBuilderBundle\Event\FeedBuilderEvent;

class ExportExample
{
    const FEED_TITLE = 'Testfeed';

    public function fileHandler(FeedBuilderEvent $event){

        if($event->getConfig()->get('title') === self::FEED_TITLE)
        {
            $arr['products'] = $event->getResult();

            $dir = PIMCORE_SYSTEM_TEMP_DIRECTORY.DIRECTORY_SEPARATOR.'export';

            $name = 'json_export_'.time().'.json';
            if(!file_exists($dir)){
                mkdir($dir);
            }
            file_put_contents($dir.DIRECTORY_SEPARATOR.$name,json_encode($arr, JSON_PRETTY_PRINT));
        }
    }
}

Now we have a writer that writes the json content to a file. Now we have to connect the listener after that the export has been runned. We will do that in the service.yml

    FeedBuilderBundle\EventListener\ExportExample:
        tags:
            - { name: kernel.event_listener, event: feedbuilder.after.run, method: fileHandler }

feedbuilderbundle's People

Contributors

faridmovsumov avatar gromtoskamp avatar jorisros avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

feedbuilderbundle's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.