ssossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

This topic contains 11 replies, has 4 voices, and was last updated by Artem Liubeznyi Artem Liubeznyi 1 year, 6 months ago.

  • Creator
    Topic
  • #17651

    archy_bold
    Participant

    Hi there.

    I’ve set up an import process for a custom entity using a ConfigurableAddOrReplaceStrategy and it imports all my data without issue.

    The problems come in the fact that I want to keep my data in sync 1:1 with what exists on the source.

    One solution would be to delete everything that’s not present in the source, but I think I’d rather have an ‘active’ flag that I can set for those in the source.

    The problem I have is how to perform either of these tasks. The reader can’t pick up lines that aren’t in the source, so I figured it might be worth implementing a second step in the import job that runs before the main import. One that essentially sets all the data to have the active flag set to false, the import will ensure all imported items have it set to true. However it seems quite OTT to write a reader, processor and writer for this process since it’s just reading rows from a database and simply updating them.

    So, is this the right approach? And if so, should I define a new instance of Step to do what I want or write the reader/processor/writer combo? Any better way to do it?

    Thanks,
    Simon

Viewing 11 replies - 1 through 11 (of 11 total)
  • Author
    Replies
  • #17663
    Dmitry Khrysev
    Dmitry Khrysev
    Oro Core

    Hi
    You solution will work. The only improvement I will suggest is to create your own processor that will update all records with DB 1 query instead of iteration over whole result set and setting flag in PHP

    #18057

    terih
    Participant

    Hello guys, i do not have any experience in OroCrm, but i have implementing import to my custom entity. Import works, but i have a question how i can clear all my old data before import new data???
    Thanks.

    #18060

    archy_bold
    Participant

    Here’s what I did to accomplish it. I first created a new Akeneo Step object.

    And then I added it as an additional step in the batch_jobs.yml file:

    The important stuff goes in the doExecute function of the Step object. It’s probably worth making quite abstract so you can use it for different tables but that should be enough to work out how to do it.

    #18068

    terih
    Participant

    Thank you archy_bold so much, for you answer, but i have one more question :).
    I implemented import throw import button, in index page, also i have implimented, ‘normalizers’, ‘data converter’, ‘trategy’, ‘processor’.Question is how i need to call this ‘batch_jobs’

    #18069

    terih
    Participant

    #normalizers
    orocrm_loyalty.importexport.normalizer.loyalty_bonus:
    class: %orocrm_loyalty.importexport.normalizer.loyalty_bonus.class%
    parent: oro_importexport.serializer.configurable_entity_normalizer
    tags:
    – { name: oro_importexport.normalizer }

    #data converter
    orocrm_loyalty.importexport.data_converter.loyalty_bonus:
    class: %orocrm_loyalty.importexport.converter.loyalty_bonus.class%
    parent: oro_importexport.data_converter.configurable

    #strategy
    orocrm_loyalty.importexport.strategy.loyalty_bonus.add_or_replace:
    class: %orocrm_loyalty.importexport.strategy.loyalty_bonus.class%
    parent: oro_importexport.strategy.configurable_add_or_replace
    arguments:
    – @doctrine

    #processor
    orocrm_loyalty.importexport.processor.import.loyalty_bonus:
    parent: oro_importexport.processor.import_abstract
    calls:
    – [setDataConverter,[@orocrm_loyalty.importexport.data_converter.loyalty_bonus]]
    – [setStrategy,[@orocrm_loyalty.importexport.strategy.loyalty_bonus.add_or_replace]]
    tags:
    – { name: oro_importexport.processor, type: import, entity: %bonus.partexchange.entity.loyalty_bonus.class%, alias: orocrm_loyalty_bonus }
    – { name: oro_importexport.processor, type: import_validation, entity: %bonus.partexchange.entity.loyalty_bonus.class%, alias: orocrm_loyalty_bonus }

    #18070

    terih
    Participant

    Index call import

    {% block navButtons %}
    {% include ‘OroImportExportBundle:ImportExport:buttons.html.twig’ with {
    entity_class: entity_class,
    importProcessor: ‘orocrm_loyalty_bonus’,
    importTitle: ‘orocrm.contact.import’|trans,
    dataGridName: gridName
    } %}
    {% endblock %}

    #18075

    terih
    Participant

    Thanks you archy_bold, i solved problem 🙂

    #18144

    archy_bold
    Participant

    Great to hear you sorted. batch_jobs.yml is for automated importing rather than through a button.

    #18157

    terih
    Participant

    Hi Guys, i implemented export in Orocrm all work good. But i have a questions how i can implement second solution, when client clicking on export button, i need launch popup in witch client can choose some extra parameters for export, for example export all records with email.

    #18167

    terih
    Participant

    ???

    #18170
    Artem Liubeznyi
    Artem Liubeznyi
    Oro Core

    Export Grid button may help with this use case. It exports only records that are displayed in the grid so you can apply desired filters first and export the resulting dataset next.

Viewing 11 replies - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.