![]() |
Illegal offset type in isset or empty - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Illegal offset type in isset or empty (/showthread.php?tid=42683) |
Illegal offset type in isset or empty - El Forum - 06-15-2011 [eluser]nvanprooyen[/eluser] I'm working on writing a API call to Magento using CodeIgniter and getting this illegal offset error. Here is an example from Magento's forum for the method I'm trying to use: Code: $proxy->call($sessionId, 'product_stock.update', array('Sku', array('qty'=>50, 'is_in_stock'=>1))); And here is the CI equivalent to that: Code: function updateProductInventory($sku) { Not sure what the problem is, all the other methods I've written functions for so far work fine. The one difference with this one, is there are several arrays in $request. I'm guessing that's what is making it choke, but I'm not positive of that. Anyone have any ideas? Illegal offset type in isset or empty - El Forum - 06-15-2011 [eluser]nvanprooyen[/eluser] This is what the $request array var_dump looks like if it's helpful... Code: array Illegal offset type in isset or empty - El Forum - 06-15-2011 [eluser]louisl[/eluser] I've not used magneto before but 'Illegal offset' usually means you're trying to access an array element that doesn't exist. I think this Code: $proxy->call( $sessionId, 'product_stock.update', array('Sku', array('qty'=>50, 'is_in_stock'=>1)) ); Should translate to this Code: $this->xmlrpc->request( $apiSession, 'product_stock.update', array($sku, array('qty'=>50, 'is_in_stock'=>1)) ); Looks to me like you have a surrounding array on your $request variable that isn't needed. Illegal offset type in isset or empty - El Forum - 06-15-2011 [eluser]nvanprooyen[/eluser] Hi Louis, Thanks for the response. Making that change is causing 2 new problems. First, CodeIgniter is having a problem w/ the foreach loop inside the XMLRPC library when it's formed that way. Here is that function: Code: function request($incoming) Secondly, Magento is returning a session expired error. Guessing that's just because the session ID isn't being passed along correctly due to the error above. It seems like an array needs to be passed along to the request method for this to work correctly, but the multiple arrays are what is screwing w/ it. Illegal offset type in isset or empty - El Forum - 06-15-2011 [eluser]nvanprooyen[/eluser] Well, forming $request this way seemed to make the issue go away (basically dropped out the array around $sku): Code: $request = array($apiSession, 'product_stock.update', $sku , array('qty'=>20, 'is_in_stock'=>1)); The function isn't updating inventory like it should still, so I'm not sure I'm passing the request along to Magento the way it needs to be formed. I think the way I had it the first time is correct for Magento, but CI is having a problem w/ it for whatever reason. Maybe the request function in the XMLRPC library needs another foreach loop to deal w/ multiple arrays? Illegal offset type in isset or empty - El Forum - 06-15-2011 [eluser]louisl[/eluser] Just had a quick look at the docs, seems if you have mixed data you need to define it's type and the whole thing does apparently have to be an array. From the docs (http://ellislab.com/codeigniter/user-guide/libraries/xmlrpc.html) "If you use data types other than strings, or if you have several different data types, you will place each parameter into its own array, with the data type in the second position:" I think that means this:- Code: $request = array ( Sorry I don't have more time to look into this, hope this helps Illegal offset type in isset or empty - El Forum - 06-15-2011 [eluser]nvanprooyen[/eluser] Thank you. It gives me another place to look for answers. I tried doing it that way and now it's causing a bunch of problems in the functions where the CI library serializes the data. Will update here in case anyone else ever runs into a similar issue. Illegal offset type in isset or empty - El Forum - 06-16-2011 [eluser]nvanprooyen[/eluser] Does anyone know of a way to see the actual XML request, that the XML-RPC class constructs? |