1. here is the model define:
<global> <models> <openerpconnector> <class>Openlabs_OpenERPConnector_Model</class> </openerpconnector>
2. here is the resource api define:
plese look at <model> node
it is important
<sales_rma translate="title" module="Openlabs_OpenERPConnector"> <model>openerpconnector/sales_rma_api</model> <title>Custom Sales RMA API</title> <methods> <search translate="title" module="Openlabs_OpenERPConnector"> <title>Return the list of products ids that match with the filter</title> <method>search</method> </search> <info translate="title" module="Openlabs_OpenERPConnector"> <title>Return the rma and detail items and history info</title> <method>info</method> </info> <list translate="title" module="Openlabs_OpenERPConnector"> <title>Return the rma list info by filter data</title> <method>retrieveRmas</method> </list> <update translate="title" module="Openlabs_OpenERPConnector"> <title>update rma and rma items status by rma id and status data</title> <method>update</method> </update> <delete translate="title" module="Openlabs_OpenERPConnector"> <title>delete rma and rma items status and histories by rma incremnt id</title> <method>delete</method> </delete> </methods> </sales_rma>
3. Api.php
<?php /** * * @author Mohammed NAHHAS * @package Openlabs_OpenERPConnector * */ class Openlabs_OpenERPConnector_Model_Sales_Rma_Api extends Mage_Sales_Model_Api_Resource { /** * Return the list of products ids that match with the filter * The filter imported is required * @param array * @return array */ public function search($data) { $result = array(); $collection = Mage::getModel("enterprise_rma/rma")->getCollection(); //->addAttributeToFilter('imported', array('eq' => $data['imported'])); if(isset($data['limit'])) { $collection->setPageSize($data['limit']); $collection->setOrder('entity_id', 'ASC'); } if(isset($data['filters']) && is_array($data['filters'])) { $filters = $data['filters']; foreach($filters as $field => $value) { $collection->addFieldToFilter($field, $value); } } foreach ($collection as $order) { $result[] = $order['increment_id']; } return $result; } /** * Retrieve full order information * * @param string $orderIncrementId * @return array */ public function info($increment_id) { $rma = null; $collection = Mage::getModel("enterprise_rma/rma")->getCollection() ->addFieldToFilter('increment_id', array('eq' => $increment_id)); foreach ($collection as $rma) { $rma = $rma; break; } $result = $this->_getAttributes($rma, 'rma'); $result['items'] = array(); $item_collection = Mage::getModel("enterprise_rma/item")->getCollection()->addFieldToFilter( 'rma_entity_id', $rma->getId() ); foreach ($item_collection as $item) { $result['items'][] = $this->_getAttributes($item, 'item'); } $result['status_history'] = array(); $history_collection = Mage::getModel('enterprise_rma/rma_status_history')->getCollection() ->addFieldToFilter('rma_entity_id',$rma->getId()); foreach ($history_collection as $history) { $result['status_history'][] = $this->_getAttributes($history, 'rma_status_history'); } return $result; } public function retrieveRmas($data) { $result = array(); $collection = Mage::getModel("enterprise_rma/rma")->getCollection(); if(isset($data['limit'])) { $collection->setPageSize($data['limit']); $collection->setOrder('entity_id', 'ASC'); } if(isset($data['filters']) && is_array($data['filters'])) { $filters = $data['filters']; foreach($filters as $field => $value) { $collection->addFieldToFilter($field, $value); } } foreach ($collection as $rma) { $tmp = $this->_getAttributes($rma, 'rma'); $result[] = $tmp; } return $result; } public function update($rma_id, $data) { $collection = Mage::getModel("enterprise_rma/rma")->getCollection() ->addFieldToFilter('increment_id', array('eq' => $rma_id)); foreach ($collection as $rma) { $rma = $rma; break; } $rma_items = Mage::getModel("enterprise_rma/item")->getCollection()->addFieldToFilter( 'rma_entity_id', $rma->getId() ); if (isset ($data['status']) && !empty($data['status'])) { $status = $data['status']; //update items status foreach ($rma_items as $item) { $qty_requested = $item->getData('qty_requested'); if ($status == Enterprise_Rma_Model_Rma_Source_Status::STATE_AUTHORIZED) { $item->setData('qty_authorized' , $qty_requested); } else if ($status == Enterprise_Rma_Model_Rma_Source_Status::STATE_APPROVED) { $item->setData('qty_approved' , $qty_requested); } else if ($status == Enterprise_Rma_Model_Rma_Source_Status::STATE_RECEIVED) { $item->setData('qty_returned' , $qty_requested); } if ($status == Enterprise_Rma_Model_Rma_Source_Status::STATE_CLOSED) { $item->setStatus(Enterprise_Rma_Model_Rma_Source_Status::STATE_DENIED); } else { $item->setStatus($status); } $item->save(); } if ($status == Enterprise_Rma_Model_Rma_Source_Status::STATE_APPROVED) { //确认完成的订单 $rma->setData('status', Enterprise_Rma_Model_Rma_Source_Status::STATE_PROCESSED_CLOSED); } elseif ($status == Enterprise_Rma_Model_Rma_Source_Status::STATE_REJECTED) { //确认拒绝收到货物的订单 $rma->setData('status', Enterprise_Rma_Model_Rma_Source_Status::STATE_CLOSED); } else { $rma->setData('status', $status); } $rma->save(); return true; } else { $this->_fault('data_invalid', "Error, the attribut 'status' need to be specified"); } } public function delete($increment_id) { try { // get rma entity $collection = Mage::getModel("enterprise_rma/rma")->getCollection() ->addFieldToFilter('increment_id', array('eq' => $increment_id)); foreach ($collection as $rma) { $rma = $rma; break; } //get grid entity $collection_grid = Mage::getModel("enterprise_rma/grid")->getCollection() ->addFieldToFilter('increment_id', array('eq' => $increment_id)); foreach ($collection_grid as $rma_grid) { $grid = $rma_grid; break; } // get history entity $history_collection = Mage::getModel('enterprise_rma/rma_status_history')->getCollection() ->addFieldToFilter('rma_entity_id',$rma->getId()); foreach ($history_collection as $hc) { $hc = $hc; $hc->delete(); } //get rma_shipping_label $shipping_collection = Mage::getModel('enterprise_rma/shipping')->getCollection() ->addFieldToFilter('rma_entity_id',$rma->getId()); foreach ($shipping_collection as $sc) { $sc->delete(); } //get items $rma_items = Mage::getModel("enterprise_rma/item")->getCollection()->addFieldToFilter( 'rma_entity_id', $rma->getId() ); foreach ($rma_items as $item) { $item->delete(); } $grid->delete(); $rma->delete(); return true; } catch (Exception $e) { var_dump($e->getMessage()); $this->_fault('data_invalid', $e->getMessage()); } } protected function _getAttributes($object, $type, array $attributes = null) { $result = array(); if (!is_object($object)) { return $result; } foreach ($object->getData() as $attribute=>$value) { $result[$attribute] = $value; } if (isset($this->_attributesMap['global'])) { foreach ($this->_attributesMap['global'] as $alias=>$attributeCode) { $result[$alias] = $object->getData($attributeCode); } } if (isset($this->_attributesMap[$type])) { foreach ($this->_attributesMap[$type] as $alias=>$attributeCode) { $result[$alias] = $object->getData($attributeCode); } } return $result; } }
4. call example:
require_once 'abstract.php'; /** * Magento Compiler Shell Script * * @category Mage * @package Mage_Shell * @author Magento Core Team <core@magentocommerce.com> */ class Mage_Shell_Test extends Mage_Shell_Abstract { /** * Run script * */ public function run() { $client = new Zend_XmlRpc_Client('http://lifemore.svn-test.com/index.php/api/xmlrpc'); $api_user = 'uername'; $api_password = '******'; $session = $client->call('login', array($api_user, $api_password)); $params = array(array('filters'=>array('increment_id'=>array('eq'=>'300000005')))); $r = $client->call('call', array($session, 'sales_rma.search',$params)); var_dump($r); } } $shell = new Mage_Shell_Test(); $shell->run();
相关推荐
magento2-blog-module-tutorial, 关于如何从头开始创建 magento 2模块的教程,带有测试 2博客模块教程这个模块是 WIP,它将被更新为每个教程我目前正在写。介绍如何从头创建完整功能的Magento 2模块。 即使有测试,...
Ajax-magento2-catalog-infinite-scroll.zip,免费的Magento 2扩展,为目录添加无限滚动功能(通过AJAX实现)编码教程,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。...
Magento 2 Module Experius电子邮件捕获器--记录器``experius/module-emailcatcher``主要功能记录所有由Magento发送的电子邮件在弹出窗口中查看电子邮件内容(用于测试和样式设置的不错) 转发收到的电子邮件重新...
Magento 2模块-内容小部件 这是一个私人模块,目前不面向公众消费。概述Augustash_ContentWidgets模块为Magento...C app/code/Augustash/ContentWidgets/bin/magento module:enable --clear-static-content Augustas
Ajax-magento2-ajax-cart-quick.zip,magento 2 ajax购物车扩展插件提供舒适的购物体验。客户可以很容易地选择可配置的选项并在弹出窗口中编辑项目,而不会浪费重新加载页面的时间。,ajax代表异步javascript和xml。它...
Ajax-magento2-ajax-layered-navigation.zip,ajax分层导航magento 2提供了一个过滤器列表,帮助您的客户以最短的方式搜索和获得他们最喜欢的产品。这个扩展应用了现代ajax技术来增强过滤系统,以提高用户对页面上每...
magento2-backup-gcp-源码.rar
edge-magento-module-customergroupoptions edge-magento-module-customergroupoptions
magento2-checkout-success-misc-script-源码.rar
Ajax-magento2-module-ajax.zip,用于ajax请求的magento 2模块,ajax代表异步javascript和xml。它是多种web技术的集合,包括html、css、json、xml和javascript。它用于创建动态网页,其中网页的小部分在不重新加载网页...
什么是magento2-module-gift-sales-rule规则Magento 2 Module? 此模块为Magento购物车价格规则功能提供了2个新操作: 根据当地条件向客户提供礼品产品 每次达到阈值时向客户提供礼品产品(例如,购物车中每30 $)...
此模块已作为Magento 2.4.0或更高版本的一部分正式移至Magento2 GitHub存储库中。 了解更多信息: : 要求 Magento社区版2.0.x-2.4.x或Magento企业版2.0.x-2.4.x 安装 支持 如果有任何问题,请如果仍然需要帮助,请...
composer require orba/magento2-module-style-guide 3.样式指南部分概述 样式指南的主要组成部分是章节。 每个部分都有一个标签和一个PHTML模板。 如果需要,节可以具有视图模型。 该部分可能被标记为已删除,
将图片上传器添加到Magento后端在后端上传的图像可以在前端int的相应页面中查看易于在任何magento安装中使用安装✓通过作曲家安装在Magento 2根文件夹中运行以下命令: composer require prateekkarki/module-...
它用于Magefan的和要求Magento社区版2.0.x-2.4.x或Magento企业版2.0.x-2.4.x安装方法1-通过composer安装打开命令行使用命令“ cd”导航到您的magento2根目录运行命令:作曲家需要magefan / module-geoip composer ...
bin/magento module:enable Smile_StoreDelivery 安装模块并重建DI缓存 bin/magento setup:upgrade 如何配置 商店>配置>销售>送货方式>商店交货 场地 类型 已启用 是/否 标题 瓦尔查 方法名称 瓦尔查 价格 小数 ...
Magento Composer 安装程序 这个项目的目的是让能够安装 Magento 模块,并自动将它们集成到 Magento 安装中。 我们强烈建议您同时阅读上的通用作曲家文档 您还应该看到 项目详情 该项目仅涵盖 composer 的自定义...
IMI StoreSwitch Magento模块扩展了默认的商店切换器,并显示所有商店视图,无论它们与之相关的商店或网站如何。 默认的magento商店切换器仅显示与当前活动商店关联的商店视图。 它扩展了核心存储开关Magento\Store\...
Magento 2的客户地址自动完成扩展在此模块中,我使用了Google的Maps Javascript API自动填写客户地址。 当客户在街道字段中输入地址时,Google Maps Javascript API将建议一个地址列表。如何安装或升级此扩展程序? ...
Magento 2已添加到购物车弹出窗口 特征: 将产品添加到购物车时显示弹出窗口。 安装扩展 composer require magekey/module-adc-popup