smalot/magento-client
Composer 安装命令:
composer require smalot/magento-client
包简介
Magento API Client (SOAP v1). Allows wrappers for each call, dependency injections and code completion.
README 文档
README
This library implements the Magento SOAP v1 (standard) API.
Features:
- allows wrappers
- allows dependencies injections
- allows code completion
- auto-updated via composer packaging (packagist.org)
Note: This library is not related to Magento Company.
Documentation
This API is designed on top of Magento SOAP API V1.
Supported modules are :
- Mage_Catalog
- Mage_CatalogInventory
- Mage_Checkout
- Mage_Customer
- Mage_Directory
- Mage_Sales
- Enterprise_CustomerBalance
- Enterprise_CustomerGiftCard
- Mage_GiftMessage
- Mage_Core
- Store View
Module's names has been standardized to be more clean :
- Catalog
- CatalogInventory
- Cart
- Customer
- Directory
- Order
- CustomerBalance
- GiftCard
- GiftMessage
- Core
- Store
Note : login and logout calls are made only if needed.
Installation
Download using composer:
{ "require": { "smalot/magento-client": "*" } }
Now tell composer to download the bundle by running the command:
$ php composer.phar update smalot/magento-client
Composer will install the bundle to your project's vendor/smalot directory and create/update an autoload file.
License
This library is provided under MIT license (since v0.5.0 release). See the complete license :
LICENSE
Implementation
Each module manager, which heritate from MagentoModuleAbstract, will generate an action.
Actions can be either directly executed or added to a queue.
If it is directly executed, it will generate a single call, if not, that's a multi call.
Single Call
Here is a sample code to load tree of categories of the default website in a single call.
<?php // Include composer's autoloader mecanism include 'vendor/autoload.php'; // Init config $path = 'http://domainname.tld/shop-folder/'; $apiUser = 'username'; $apiKey = 'xxxxxxxxxxxxxxxxxxx'; // Create remote adapter which wrap soapclient $adapter = new \Smalot\Magento\RemoteAdapter($path, $apiUser, $apiKey); // Call any module's class $categoryManager = new \Smalot\Magento\Catalog\Category($adapter); $tree = $categoryManager->getTree()->execute(); var_dump($tree);
Multi Call
Multi call is only available on Magento Soap v1.
That's why this library is built on top of Magento Soap v1.
This function allows to group multiple soap calls into only one http request, which can be a very great optimization practice.
It removes network latency and reduce magento bootstrap processes.
Tipically, it can be used to synchronize a whole product catalog into very few number of calls.
<?php // Include composer's autoloader mecanism include 'vendor/autoload.php'; // Init config $path = 'http://domainname.tld/shop-folder/'; $apiUser = 'username'; $apiKey = 'xxxxxxxxxxxxxxxxxxx'; // Create remote adapter which wrap soapclient $adapter = new \Smalot\Magento\RemoteAdapter($path, $apiUser, $apiKey); // Build the queue for multicall $queue = new \Smalot\Magento\MultiCallQueue($adapter); // Call any module's class $productManager = new \Smalot\Magento\Catalog\Product($adapter); $productManager->getInfo(10)->addToQueue($queue); $productManager->getInfo(11)->addToQueue($queue); $productManager->getInfo(12)->addToQueue($queue); // Request in one multicall information of 3 products (#10, #11, #12) $products = $queue->execute(); var_dump($products);
Callback support for multicall
<?php // Include composer's autoloader mecanism include 'vendor/autoload.php'; // Init config $path = 'http://domainname.tld/shop-folder/'; $apiUser = 'username'; $apiKey = 'xxxxxxxxxxxxxxxxxxx'; // Create remote adapter which wrap soapclient $adapter = new \Smalot\Magento\RemoteAdapter($path, $apiUser, $apiKey); // Build the queue for multicall $queue = new \Smalot\Magento\MultiCallQueue($adapter); // Local catalog adapter $localAdapter = new LocalAdapter(....); // Store categories $categoryManager = new \Smalot\Magento\Catalog\Category($adapter); $categoryManager->getTree()->addToQueue($queue, array($localAdapter, 'updateCategories')); // Store products into local catalog $productManager = new \Smalot\Magento\Catalog\Product($adapter); $productManager->getInfo(10)->addToQueue($queue, array($localAdapter, 'updateProduct')); $productManager->getInfo(11)->addToQueue($queue, array($localAdapter, 'updateProduct')); $productManager->getInfo(12)->addToQueue($queue, array($localAdapter, 'updateProduct')); // Update local catalog $products = $queue->execute();
smalot/magento-client 适用场景与选型建议
smalot/magento-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 141.65k 次下载、GitHub Stars 达 78, 最近一次更新时间为 2013 年 10 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 smalot/magento-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 smalot/magento-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 141.65k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 79
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-10-25