首页 > 解决方案 > 通过 Magento 1.9 自定义愿望清单 SOAP API 添加时,产品仅在管理员中显示

问题描述

要求:我是一个新手,magentoSOAP在 Magento 1.9 中创建一个自定义 API 来管理愿望清单。我需要将它连接到正在 ionic V1 中开发的 android 应用程序。
起初我尝试使用这个扩展magento-api但找不到在 android 中维护会话信息的方法。所以,我开始开发自己的 API。
我能够获取愿望清单信息(wishlist_id、项目等)并添加到其中。

问题:但是通过肥皂电话在愿望清单中添加产品后,它只显示在客户的管理区域而不是网站的前端(用户已登录)。只有从前端(浏览器)添加的产品才会显示在前端愿望清单页面上。

在将前端的功能 /app/code/core/Mage/Wishlist/controllers/IndexController.php( 我已将 Api.php 添加到.$buyRequest

/app/code/core/Mage/Wishlist/ModelApi.php

我将产品添加到愿望清单的代码如下:

public function create($customer_id, $product_id, $store = null){
    $return_result = array(
        'code' => 0,
        'msg' => null,
        'model' => null,
        'customer_id' => $customer_id,
        'product_id' => $product_id
    );
    $buyRequest = new Varien_Object(array());
    $params = array('product' => $product_id,
            'qty' => 1,
            'store_id' => $store,
            );
    $buyRequest->setData($params);

    $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer_id, true);
    $product = Mage::getModel('catalog/product')->load($product_id);
    $result = $wishlist->addNewItem($product, $buyRequest);

    Mage::helper('wishlist')->calculate();
    if($result){
        $return_result['msg'] = 'Product '.$product_id.' Added ';
        $return_result['model'] = $result;
    }  
    return json_encode($return_result);
}

我使用以下链接来实现添加功能并使用/app/code/core/Mage/Wishlist/controllers/IndexController.php文件中的一些代码:在 magento 中以编程方式在愿望清单中添加目录产品

任何帮助将不胜感激。

标签: phpsoapmagento-1.9

解决方案


推荐阅读