0

我正在寻找一些帮助来创建基于 API 的模块,以将客户信息从 Magento 推送到第三方忠诚度计划中。

到目前为止,我已经创建了一个基本模块,但找不到任何关于在 Magento 中创建基于 API 的模块的好信息,并且真的可以提供一些建议......

我需要以某种方式连接到 Magneto 中的结帐成功页面,并添加一个表格,将客户信息(姓名、地址等)发布到第三方忠诚度计划。我还需要能够登录以完成帐单信息等...

有谁知道这种实现的任何方便的教程或文档?

到目前为止,我已经设置了一个具有适当角色的 API 用户。我还为测试目的创建了一个非常基本的模块,但浏览到文件时出现 404 错误

apitest.php

<?php 
$proxy = new SoapClient('http://mysite.com/api/?wsdl'); //edit the address and put the url to your magento here

$sessionId = $proxy->login('######', '#######'); // put in the info for your user here

echo "Login ID : $sessionId";
$result = $proxy->call($sessionId, 'Mymodule.testConnection', array('param1' => ' This string was sent from soap client'));
echo $result; 

对象模型/api.php

<?php
class MyModule_MyModule_Model_ObjectModel_Api extends Mage_Api_Model_Resource_Abstract
{
    public function testConnection($arg)
    {
        return "Hello World! My argument is : " . $arg;
    }
}

如果有人可以帮助我进行正确的设置,我将按照此处的示例启动并运行基本的“Hello world”模块,我将不胜感激

4

1 回答 1

1

您可以像这样创建客户,而不是连接 magento API。

define('INCLUDE_PATH', '/var/www/QA/mojostage/app/');
define('INCLUDE_FILE', 'Mage.php');
Mage::app();
$customer = Mage::getModel('customer/customer');
        $customer->setWebsiteId($wesite_id);
        $customer->loadByEmail($customer_email);
        /*
         * Check if the email exist on the system.
         * If YES,  it will not create a user account.
         */

        if (!$customer->getId()) {

            //setting data such as email, firstname, lastname, and password

            $customer->setEmail($customer_email);
            $customer->setTaxvat($value['cus_vatnumber'])
                    ->setCreatedAt($date1)
                    ->setDob($value['date_of_birth'])
                    ->setGroupId($cus_group_id)
                    ->setConfirmation($is_active)
                    ->setCreatedIn('Admin')
                    ->setStoreId($store_id)
                    ->setWebsiteId($wesite_id)
                    ->setEntityId($value['cus_id']);
            $customer->setFirstname($customer_fname);
            $customer->setLastname($customer_lname);
            $customer->setPassword($value['password']);

            $subscriber = Mage::getModel('newsletter/subscriber');
            $subscriber->setStoreId($store_id)
                    ->setCustomerId($value['cus_id'])
                    ->setSubscriberEmail($customer_email)
                    ->setSubscriberStatus($value['cus_spam'])
                    ->setSubscriberConfirmCode($subscriber->randomSequence());
        }

        //the save the data and send the new account email.
        $customer->save();
        $subscriber->save();
于 2013-03-13T09:55:57.953 回答