php - 通过 Magento 1.9 自定义愿望清单 SOAP API 添加时,产品仅在管理员中显示
问题描述
要求:我是一个新手,magento
想SOAP
在 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 中以编程方式在愿望清单中添加目录产品
任何帮助将不胜感激。
解决方案
推荐阅读
- python - python解释器的两个实例之间如何通信?
- jcl - DFSORT 中的求和字段
- setuptools - 将自定义操作添加到 setup.py
- r - R删除列名中某些字符之前的所有内容
- javascript - 是否可以替换脚本或将更多功能附加到 DOM 内的脚本
- asp.net-core - 在 ABP 框架中为 IdentityUser 启用 AuditLog EnityChanges
- css - 我不能同时使用位置固定和线性渐变。为什么?
- node.js - Express.js | http服务器在接受请求后没有立即开始执行代码
- python - 有没有办法获取 xml 元素?
- python - 如何使用基于“mnist”示例的 tensorflow.dataset 从 opus/medical 中提取特征和目标