OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Import – Clear Old Data

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

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #34137

    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
  • #34138

    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

    #34139

    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.

    #34140

    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.

    #34141

    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’

    #34142

    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 }

    #34143

    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 %}

    #34144

    terih
    Participant

    Thanks you archy_bold, i solved problem :)

    #34145

    archy_bold
    Participant

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

    #34146

    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.

    #34147

    terih
    Participant

    ???

    #34148

    Artem Liubeznyi
    Spectator

    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)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top

You will be redirected to [title]. Would you like to continue?

Yes No

You will be redirected to [title]. Would you like to continue?

Yes No