magento Web服务过滤器产品列表错误在非对象上调用成员函数getBackend() [英] magento web service filter product list error Call to a member function getBackend() on a non-object

查看:83
本文介绍了magento Web服务过滤器产品列表错误在非对象上调用成员函数getBackend()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2010服务参考来使用magento soap v2 api Web服务.

I'm using visual studio 2010 service reference to consume magento soap v2 api web service.

php 5.3.8,magento 1.6安装在Windows 7 iis 7.5上

php 5.3.8, magento 1.6 install on windows 7 iis 7.5

我可以登录并列出所有产品,但是一旦我放入过滤器,就会出现异常

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

在非对象上调用成员函数getBackend()

Call to a member function getBackend() on a non-object

php错误日志:

PHP致命错误:在第816行的C:\ inetpub \ wwwroot \ Magento1620 \ app \ code \ core \ Mage \ Eav \ Model \ Entity \ Abstract.php的非对象上调用成员函数getBackend()

PHP Fatal error: Call to a member function getBackend() on a 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);
    }

请帮助

谢谢

推荐答案

这似乎是Magento的错误,但是由于我不是PHP开发人员,因此不确定,它可能只反映了Magento和PHP在Windows上的安装

It seems to be a Magento bug, but I'm not sure since I'm not a PHP developer, it may only reflect Magento and PHP install on windows

修改此文件

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

第57-62行

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

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

我还注意到,在不同的V2.php文件中,这段代码是用不同的方式编写的.客户API与产品相同,但是订单API的编写方式如下

I also notice that in different V2.php file, this piece of code is written differently. The customer API is the same as product, but the order API is written like this

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

任何人都可以指出PHP中正确的数组用法吗?

anyone can point out the correct array usage in PHP?

这篇关于magento Web服务过滤器产品列表错误在非对象上调用成员函数getBackend()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆