Myapi_Myconf Magento Module: Soap v1 API Example

You will find below an example how to use my Myapi_Myconf Magento Module.

Note: An Soap v2 Client API WSDL-WS-I compliant example is available into my Myapi_Myconf Magento module.

Below the Soap v1 Client API Example :

<?php

/**
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category    Soap API client WSDL/WS-I Source Code Example of Configurable Product Creation
* @copyright   Copyright (c) 2014 Nicolas Portais (http://www.nportais.org/)
* @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*/

// Initialization of the Soap Client Class
// Change HOSTNAME by your store URL
$client = new SoapClient('https://HOSTNAME/api/soap/?wsdl');

// login : Specify your Login and Password
$session = $client->login('login', 'password');

// Retrive attribute Sets
$attrset = $client->call($session, 'catalog_product_attribute_set.list');

// My Configurable Products Data Array
$configurableProductsData = array(

array(
'product_id' => '783', // Change by your simple product ID
'label' => '20x30',
'is_percent' => 0,
'pricing_value' => ''
),
array(
'product_id' => '784', // Change by your simple product ID
'label' => '30x45',
'is_percent' => 0,
'pricing_value' => '15'
),
array(
'product_id' => '785', // Change by your simple product ID
'label' => '40x60',
'is_percent' => 0,
'pricing_value' => '36'
)
);

// My configurable attributes data Array
$configurableAttributesData = array(
array(
'attribute_code' => 'format',
)
);

// SKU : Change with Yours
$sku='PLEXI257617171';

// Create Product Array
$myproductData=array(
'categories' => array(5),
'websites' => array(1),
'name' => "Titre Plexiglass (plexiglass)",
'description' => "Description ....",
'short_description' => "Titre",
'weight' => 0.200,
'status' => 2,
'stock_data' => array(
'use_config_manage_stock' => 0,
'manage_stock' => 1, // We do not manage stock, for example
'qty' => 30,
'is_in_stock' => 1,
'min_qty' => 1,
'max_sale_qty' => 1,
),
'url_key' => 'product-id-'.$sku,
'url_path' => 'poster-',
'visibility' => 4, // 1 = Not visible, 2 = Catalog, 3 = Search, 4 = Catalog/Search
'category_ids' => array(5,18),
'website_ids' => array(1),
'has_options' => '',
'gift_message_available' => '',
'price' => 90,
// 'special_price' => 0,
'tax_class_id' => 0, // 0 = None , 2 = Taxable Goods, 4 = Shipping
'meta_title' => "Titre",
'meta_keyword' => "keywords",
'meta_description' => "Titre",
'page_layout' => 'two_columns_left',
'options_container' => 'container1'
);

// Call My API to Create the Configurable Product Data
// Change $attrset[1]['set_id'] to yours
$result = $client->call($session, 'conf_product.create', array('configurable',$attrset[1]['set_id'],$sku,$myproductData,  $configurableProductsData, $configurableAttributesData));
var_dump($result);
?>

You can purchase my module here.

You may be interrested by my Magento Module API  : Myapi_Myconf !

Nicolas Portais
Author Photographer
http://www.mystockphoto.fr

Ce contenu a été publié dans Magento Module, avec comme mot(s)-clé(s) , , , . Vous pouvez le mettre en favoris avec ce permalien.