2

How to create Shopping cart promotion rule using SOAP API?

1

Hi you need create a custom module which will send

Step1: Create model api file for which is create which is ceate coupon at location app\code\local\Amit\CreatePromo\Model\Api.php and copy code from http://marius-strajeru.blogspot.in/2010/04/create-bulk-discount-rules.html

<?php
class Amit_CreatePromo_Model_Api extends Mage_Api_Model_Resource_Abstract
{        
        public function createpromotion()
        {
        }
}

Step2: create api.xml which is call this model file at app\code\local\Amit\CreatePromo\etc\api.xml file:

code is :

<?xml version="1.0"?>
<config>
    <api>
        <resources>
            <createpromo_api translate="title" module="createpromo">
                <title>Myapi</title>
                <acl>createpromo/api</acl>
                <model>createpromo/api</model>
                <methods>                    
                        <createpromotion translate="title" module="createpromo">
                            <title>Ceate Shopping Cart rules</title>
                            <acl>createpromo/createpromotion</acl>
                        </createpromotion>
                </methods>
            </createpromo_api>
        </resources>
        <acl>
            <resources>
                <createpromo translate="title" module="createpromo">
                    <title>CreatePromo</title>
                    <sort_order>2000</sort_order>                    
                    <createpromotion translate="title" module="createpromo">
                        <title>Ceate Shopping Cart rules</title>
                    </createpromotion>
                </createpromo>
            </resources>
        </acl>
    </api>
</config>

Step3: create config file which is define helper and model class at \app\code\local\Amit\CreatePromo\etc\config.xml and code is

<?xml version="1.0"?>
<config>
  <modules>
    <Amit_CreatePromo>
      <version>1.0.0</version>
    </Amit_CreatePromo>
  </modules>
  <global>
    <helpers>
      <createpromo>
        <class>Amit_CreatePromo_Helper</class>
      </createpromo>
    </helpers>
    <models>
      <createpromo>
        <class>Amit_CreatePromo_Model</class>
        <resourceModel>createpromo_mysql4</resourceModel>
      </createpromo>
    </models>
  </global>
</config> 

Step4: define helper class at app\code\local\Amit\CreatePromo\Helper\Data.php and code is

<?php
class Amit_CreatePromo_Helper_Data extends Mage_Core_Helper_Abstract
{
}

Step5: Create modules file at Amit_CreatePromo\app\etc\modules\Amit_CreatePromo.xml

and code is

<?xml version="1.0"?>
<config>
  <modules>
    <Amit_CreatePromo>
      <active>true</active>
      <codePool>local</codePool>            
            <depends>
                <Mage_Api />
            </depends>
      <version>1.0.0</version>
    </Amit_CreatePromo>
  </modules>
</config>

You can fetch data using below link

SOAP

$client = new SoapClient('http://yourhost/api/soap/?wsdl');
$session = $client->login('******', '******');
$date = $client->call($session, 'createpromo_api.createpromotion');

XML-RPC

$client = new Zend_XmlRpc_Client('http://yourhost/api/xmlrpc/');
$session = $client->call('login', array('******', '******'));
$date=$client->call('call', array($session, 'createpromo_api.createpromotion'));

MOre update soon

Not the answer you're looking for? Browse other questions tagged or ask your own question.