Forums

Covering OroCommerce, OroCRM, OroPlatform topics, including community updates and company announcements.

Forums OroCRM OroCRM – How do I? Questions How do I sync Magento Customer "On-Demand"?

This topic contains 13 replies, has 2 voices, and was last updated by Mike Kudelya Mike Kudelya 1 year, 9 months ago.

  • Creator
    Topic
  • #29193
    oro_newbie
    oro_newbie
    Participant

    Hello,

    Is it possible to use the Magento’s SOAP API or any other way so that I can pass the customer ID to Magento and it syncs all the details of that particular customer?

    Although having the integration sync running all the time can get me all the details of all the customers, syncing “On-Demand” for a particular customer seems to be a good option to add too. Is this currently possible?

    Also, as a side question, how does the integration sync work? I mean when there’s a new customer in Magento, how does OroCRM know when to pull this detail because I don’t find the integration sync command running on its own.

    Thank you for your support!

Viewing 13 replies - 1 through 13 (of 13 total)
  • Author
    Replies
  • #29194
    Mike Kudelya
    Mike Kudelya
    Participant

    Hi

    Is it possible to use the Magento’s SOAP API or any other way so that I can pass the customer ID to Magento and it syncs all the details of that particular customer?

    Yes, it is possible, i have modified CustomerBridgeIterator.php and add additional filter on this line.

    Also, as a side question, how does the integration sync work? I mean when there’s a new customer in Magento, how does OroCRM know when to pull this detail because I don’t find the integration sync command running on its own.

    Magento customer has own customer id, orocrm saves it to orocrm_magento_customer::origin_id field and findExistingEntity function is searching by this field and decides – new entity or not.

    #29195
    oro_newbie
    oro_newbie
    Participant

    Hi Mike,

    Thanks for the reply. So I understood that we need to add the customer ID filter to get details of that particular customer. How do I do this based on a button-click? should I override the CustomerBridgeIterator.php while passing an option ID parameter to applyFilter()? And then call the applyFilter() method?

    As for the integration sync, what I really meant was I don’t see the cron for integration running unless I click the ‘Schedule Sync’ button so I was wondering how the cron is actually supposed to be configured for the sync to run on a regular basis without me clicking.

    Thanks again!

    #29196
    Mike Kudelya
    Mike Kudelya
    Participant

    Hi

    If you want to sync only one customer, just override original CustomerBridgeIterator.php and paste this function in your new file:

    In other case, if you want to specify list of customers which should be synchronized from UI, you should add to MagentoSoapTransport entity Many-To-Many relation to Magento Customer, add to settings your filtered array of customers, modify SoapTransportSettingFormType form. After that add array of customers to AbstractPageableSoapIterator, for example what this did with $this->websiteId and change call from “‘value’ => 145” to new variable “‘value’ => $this->filtered_customers”. Don’t forget change ‘key’ from ‘eq’ to ‘in’. In this case you can create many integrations with different list of customers which will be synchronized.

    To run on a regular basis try to add this command to cron:

    #29197
    oro_newbie
    oro_newbie
    Participant

    Thank you Mike.

    It was well explained. I’ll try and let you know how it goes.

    #29198
    oro_newbie
    oro_newbie
    Participant

    Hi again Mike,

    Here’s how I override the CustomerBridgeIterator.php:

    So if you see while I’m running the integration sync it should give me an output ‘method overridden’ which it isn’t. I even completely removed the cache folder and ran clear:cache.

    Do you think I’m doing something wrong or is the above meant to be? Thank you.

    #29199
    Mike Kudelya
    Mike Kudelya
    Participant

    Hi

    Please read my topic about overriding. There is two ways to override.

    #29200
    oro_newbie
    oro_newbie
    Participant

    Hi Mike,

    I followed your guide and declared the CustomerBridgeIterator as a service in service.yml:

    And the service.yml is being loaded in CustomMagentoExtension.php but the overridden class is still not being picked. I tried the above with an iterator.yml too.

    I noticed that the way the original CustomerBridgeIterator is being used not through a service call but by direct class call. Do you think this is the issue?

    Thank you.

    #29201
    oro_newbie
    oro_newbie
    Participant

    I found my mistake. The problem was not with overriding but I was calling the base function because of this:

    I was calling the parent getEntityIds() which calls $this->applyFilter() and thus the base function was being called.

    Changed to this:

    But now I seem to be getting another error:

    Any ideas? Thank you.

    #29202
    oro_newbie
    oro_newbie
    Participant

    Please excuse my answer above. I thought that fixed the issue but it actually didn’t. My file is still not being overridden. I feel I’m either missing something very silly or very crucial.

    #29203
    Mike Kudelya
    Mike Kudelya
    Participant

    Hi

    I think I understood what was wrong. SoapTransport creates CustomerBridgeIterator via new operator, not call service. Override getCustomers function and create there your custom CustomerBridgeIterator class. Please note, ‘orocrm_magento.transport.soap_transport.class’ parameter in your custom bundle must be the same that in original MagentoBundle, just change path to class.

    #29204
    oro_newbie
    oro_newbie
    Participant

    Hi Mike,

    You were perfectly correct. The reason is exactly as you said. My overridden function now works! Thank you so much.

    #29205
    oro_newbie
    oro_newbie
    Participant

    Hello Mike,

    So all my code is set up but the intended response is not showing through SOAP. When I apply the filter for a single customer_id it returns no records. However, if I remove the filter it returns all the customers. Here’s the filter being passed:

    However, this works returning all customers for that website:

    Customer ID 9503 belongs to Website 7, this has already been verified. This is the empty SOAP response that I receive with the Customer ID:

    Maybe the filters are not configured to work for this action with OroBridge? Or there’s another way to insert this filter? I tried using action ‘OroCustomerInfo’ too.

    Thank you in advance!

    #29206
    Mike Kudelya
    Mike Kudelya
    Participant

    Hi

    Here is my customer filter from applyFilter function:

    I think they are the same with your filter, but i can update my customer. Are you sure that field updated_at in customer_entity magento table contain value between ‘2016-01-01 12:00:00’ and ‘2017-01-19 05:57:42’ ? Also try to print all filters on magento side.

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

You must be logged in to reply to this topic.

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

Yes No
sso for www.magecore.comsso for oroinc.comsso for oroinc.desso for oroinc.frsso for marketplace.orocommerce.comsso for marketplace.orocrm.com