Page 1 of 1

How to Debug Magento Integration Plugin

PostPosted: Fri Mar 04, 2016 10:33 pm
by Ahmed
Hi,

I want to debug an export request & found out that inserting break points on dll file code isn't possible,
but like Mike said here in his 2nd reply https://forums.jiwa.com.au/viewtopic.php?f=23&t=555

if you're a developer I'd recommend the following from there:

- Setup an environment with both Jiwa 7.00.149.00 installed and Visual Studio (2015 recommended, even the express / community edition is fine)
- Add a System.Diagnostics.Debugger.Break() in the plugin code in the part where it dequeues inventory items from Jiwa to export to the store
- Run the export of products and the breakpoint will be hit
- Step through the code until the error occurs - report back here the part of the plugin which caused the error.
.

can you explain how to do that ?

Thanks

Re: How to Debug Magento Integration Plugin  Topic is solved

PostPosted: Wed Mar 09, 2016 9:35 am
by Mike.Sheen
At the desired point in the plugin, put in the following line:

Code: Select all
System.Diagnostics.Debugger.Break();


In your particular case, we were interested in debugging why the Export of Inventory items from Jiwa to Magento was failing, so you want to find a method named "CreateOrUpdateMagentoProductsFromJiwa" and put your breakpoint there.

Code: Select all
public void CreateOrUpdateMagentoProductsFromJiwa(MagentoIntegration MagentoIntegration, IntegrationAction IntegrationAction, BackgroundWorker worker, DoWorkEventArgs e)
        {
         System.Diagnostics.Debugger.Break();
         
            // Read the entire queue
            MagentoIntegration.Queues["Jiwa Inventory"].QueueCollection.Read(new MagentoQueueItem.ItemStatuses[] { MagentoQueueItem.ItemStatuses.Pending, MagentoQueueItem.ItemStatuses.Exception });
            MagentoIntegration.LogActivity(String.Format("Found {0} items in queue '{1}'", MagentoIntegration.Queues["Jiwa Inventory"].QueueCollection.Count, MagentoIntegration.Queues["Jiwa Inventory"].QueueCollection.QueueName), JiwaMagento.IntegrationAction.LoggingPolicyTypes.Verbose, IntegrationAction);


Save the plugin changes, quit Jiwa and log back in.

Now load up Visual Studio (Any version should do, but I'm using VS 2015).

Press CTRL-ALT-P to load the "Attach to process" dialog - find Jiwa.exe in the list of processes and press the "Attach" button.
AttachToProcess.PNG
Attach to Process Dialog


Now back in Jiwa, we just need to run a configuration to hit the break point - To keep things simple, create a new Configuration and just add the "Export Jiwa Inventory Items" to the selected actions:
TestIntegrationAction.PNG
Test Integration Action


Save the action, then press the "Run Selected Actions" button - Visual Studio will then appear:
VSDebugging.PNG
Visual Studio Debugging


From there you can step through the code and examine variable/object contents as you go.

Now - Ahmed - for your problem this isn't going to help you because I've found even using SOAPUI I get a fault when talking to your store - I'll talk about that some more on your thread.