I can not find the REST API documentation for creating a configurable product over the REST API from Magento
I also can not find the documentation for relating simple products with a product over REST.
apiconfigurable-productgrouped-productsproductrest
I can not find the REST API documentation for creating a configurable product over the REST API from Magento
I also can not find the documentation for relating simple products with a product over REST.
I have create new extension which is give the relational diagram of simple products and parent Configurable product.
Step1>: Create Api.php
at app\code\local\Amit\SimpleConfigRelation\Model
this give simple product ids and it reverent variance value and attribute id
and option id and label
code is
<?php
class Amit_SimpleConfigRelation_Model_Api extends Mage_Catalog_Model_Api_Resource
{
public function getRelationship($productId, $storeId = null){
$result = array();
$this->_configProductId =$productId;
$product = $this->_getProduct($productId, $storeId);
$this->_getProduct = Mage::getModel('catalog/product');
// $this->_getProduct->setStoreId($storeId);
$this->_getProduct->load($productId);
if($this->_getProduct->getId()){
$result['dropdata']=$this->alldropdownData();
}
return $result;
}
public function getChildsByParentId()
{
}
public function getVarienPrice()
{
}
public function alldropdownData()
{
$attributes = array();
$options = array();
$currentProduct = $this->_getProduct;
$products = array();
$skipSaleableCheck = Mage::helper('catalog/product')->getSkipSaleableCheck();
/* getting all all simple products */
$allProducts = $this->_getProduct->getTypeInstance(true)
->getUsedProducts(null, $this->_getProduct);
foreach ($allProducts as $product) {
$products[] = $product;
}
/* getting all configurable attribute of that products */
$AllowAttributes=$this->_getProduct->getTypeInstance(true)
->getConfigurableAttributes($this->_getProduct);
$producVarien=array();
foreach ($products as $product) {
$productsData[$product->getId()]=$product->getData();
foreach ($AllowAttributes as $attribute) {
$productAttribute = $attribute->getProductAttribute();
$productAttributeId = $productAttribute->getId();
$attributeValue = $product->getData($productAttribute->getAttributeCode());
/* Simple Product data */
if (!isset($producVarien[$product->getId()])) {
$producVarien[$product->getId()] = array();
}
if (!isset($producVarien[$product->getId()][$productAttributeId])) {
$producVarien[$product->getId()][$productAttributeId] = array();
}
/* getting option text value */
if ($productAttribute->usesSource()) {
$MYabel = $productAttribute->getSource()->getOptionText($attributeValue );
}else{
$MYabel='';
}
$info = array(
'id' => $productAttribute->getId(),
'code' => $productAttribute->getAttributeCode(),
'label' => $attribute->getLabel(),
'optionslabel' => $MYabel
);
$producVarien[$product->getId()][$productAttributeId] = array('value'=>$attributeValue,'all'=>$info );
/* end of simple product data */
if (!isset($options[$productAttributeId])) {
$options[$productAttributeId] = array();
}
if (!isset($options[$productAttributeId][$attributeValue])) {
$options[$productAttributeId][$attributeValue] = array();
}
$options[$productAttributeId][$attributeValue][] = $productId;
}
}
return $producVarien;
}
}
[Result]
Step2: Create api.xml
at app\code\local\Amit\SimpleConfigRelation\etc
for getting their relation by api access
SOAP
$client = new SoapClient('http://yourhost/api/soap/?wsdl');
$session = $client->login('******', '******');
$date = $client->call($session, 'simpleconfigrelation_api.getrelationship',array($configproID));
XML-RPC
$client = new Zend_XmlRpc_Client('http://yourhost/api/xmlrpc/');
$session = $client->call('login', array('******', '******'));
$date=$client->call('call', array($session, 'simpleconfigrelation_api.getrelationship'));
And code of this file
<?xml version="1.0"?>
<config>
<api>
<resources>
<simpleconfigrelation_api translate="title" module="simpleconfigrelation">
<title>Myapi</title>
<acl>simpleconfigrelation/api</acl>
<model>simpleconfigrelation/api</model>
<methods>
<getrelationship translate="title" module="simpleconfigrelation">
<title>Relation Between</title>
<acl>simpleconfigrelation/getrelationship</acl>
</getrelationship>
<getchildsbyparentid translate="title" module="simpleconfigrelation">
<title>Child Product iDs</title>
<acl>simpleconfigrelation/getchildsbyparentid</acl>
</getchildsbyparentid>
<getvarienprice translate="title" module="simpleconfigrelation">
<title>Get Extra price on Varien</title>
<acl>simpleconfigrelation/getvarienprice</acl>
</getvarienprice>
</methods>
</simpleconfigrelation_api>
</resources>
<acl>
<resources>
<simpleconfigrelation translate="title" module="simpleconfigrelation">
<title>SimpleConfigRelation</title>
<sort_order>2000</sort_order>
<getrelationship translate="title" module="simpleconfigrelation">
<title>Relation Between</title>
</getrelationship>
<getchildsbyparentid translate="title" module="simpleconfigrelation">
<title>Child Product iDs</title>
</getchildsbyparentid>
<getvarienprice translate="title" module="simpleconfigrelation">
<title>Get Extra price on Varien</title>
</getvarienprice>
</simpleconfigrelation>
</resources>
</acl>
</api>
</config>
Step3: Create config.xml
at app\code\local\Amit\SimpleConfigRelation\etc
and
code is
<?xml version="1.0"?>
<config>
<modules>
<Amit_SimpleConfigRelation>
<version>0.1.0</version>
</Amit_SimpleConfigRelation>
</modules>
<global>
<helpers>
<simpleconfigrelation>
<class>Amit_SimpleConfigRelation_Helper</class>
</simpleconfigrelation>
</helpers>
<models>
<simpleconfigrelation>
<class>Amit_SimpleConfigRelation_Model</class>
<resourceModel>simpleconfigrelation_mysql4</resourceModel>
</simpleconfigrelation>
</models>
</global>
</config>
Step4:create module file at Amit_SimpleConfigRelation.xml
at app\etc\modules
and code is
<?xml version="1.0"?>
<config>
<modules>
<Amit_SimpleConfigRelation>
<active>true</active>
<codePool>local</codePool>
<depends>
<Mage_Api />
</depends>
<version>0.1.0</version>
</Amit_SimpleConfigRelation>
</modules>
</config>
Study on How can I create a Custom SOAP/XML-RPC v1 & V2 Api in magento?
I know it's an old question, but I hope someone would find it useful.
You need to use another endpoint to get the configurable product price.
/rest/V1/configurable-products/:sku/children
Each product children might be having their own price.
So you need to find a lower price or any reasonable way from the children to display the configurable product price in a category list. Also in default product detail display.
Because each product children might be having different price. You need to get the correct price based on the selected configurable product options.
You can see all the options below the "extension_attributes" -> "configurable_product_options" property or using below endpoint :
/rest/V1/configurable-products/:sku/options/all
To display the options correct values, you need to get all available product attributes using below endpoint :
/rest/V1/products/attributes?searchCriteria[filterGroups][0][filters][0][field]=is_visible&searchCriteria[filterGroups][0][filters][0][value]=1&searchCriteria[filterGroups][0][filters][0][conditionType]=eq&searchCriteria[filterGroups][1][filters][0][field]=is_user_defined&searchCriteria[filterGroups][1][filters][0][value]=1&searchCriteria[filterGroups][1][filters][0][conditionType]=eq
Check & modify the query param for your best result. Also by the time I answer this question, you cannot test this endpoint using plain Postman request, you need to pass the Authorization header.
Then display the options based on the "configurable_product_options" property.
Best Answer
None of this exists for the RESTful API. We created all this functionality as well as the relation of products and CRUD for categories. (They exist as SOAP now)