Magento web service filter product list error Call the getBackend () member function for a non-object

I am using the link to Visual Studio 2010 to use the magento soap v2 api web service.

php 5.3.8, magento 1.6 install on windows 7 iis 7.5

I can log in and list the entire product, but as soon as I put in the filter, there is an exception

Call a member function getBackend () for a non-object

Php error log:

PHP Fatal error: call getBackend () member function for non-object in C: \ inetpub \ wwwroot \ Magento1620 \ app \ code \ core \ Mage \ Eav \ Model \ Entity \ Abstract.php on line 816

static void TestMagentoSoapV2Wcf() { MagentoService magentoService = new MagentoService(); MageSvcRef.associativeEntity assoEntity = new MageSvcRef.associativeEntity(); assoEntity.key = "like"; assoEntity.value = "n2610"; MageSvcRef.complexFilter complexFilter = new MageSvcRef.complexFilter(); complexFilter.key = "sku"; complexFilter.value = assoEntity; MageSvcRef.complexFilter[] compFilters = new MageSvcRef.complexFilter[1]; compFilters[0] = complexFilter; MageSvcRef.filters filters = new MageSvcRef.filters(); filters.complex_filter = compFilters; string sessionId = magentoService.login("zzc000", "zzc000"); var products = magentoService.catalogProductList(sessionId, filters, string.Empty); } 

Please, help

thanks

+1
source share
1 answer

This seems to be a Magento bug, but I'm not sure, since I'm not a PHP developer, it can only display Magento and PHP for installation on windows

change this file

 \app\code\core\Mage\Catalog\Model\Product\Api\V2.php 

line 57-62

 foreach ($filters->complex_filter as $_filter) { $_value = $_filter->value; $preparedFilters[$_filter->key] = array( $_value->key => $_value->value ); } 

to

 foreach ($filters->complex_filter as $_field => $_filter) { $preparedFilters[$_field] = array( $_filter->key => $_filter->value ); } 

I also notice that in another V2.php file this piece of code is written differently. The client API is the same as the product, but the order API is written as follows:

 foreach ($filters->complex_filter as $_filter) { $_value = $_filter->value; if(is_object($_value)) { $preparedFilters[][$_filter->key] = array( $_value->key => $_value->value ); } elseif(is_array($_value)) { $preparedFilters[][$_filter->key] = array( $_value['key'] => $_value['value'] ); } else { $preparedFilters[][$_filter->key] = $_value; } } 

can anyone indicate the correct use of an array in PHP?

+1
source

Source: https://habr.com/ru/post/906012/


All Articles