我使用Magento 1.5.1.0。 我想通过PHP脚本添加产品。 我有一个自定义属性与8个自定义属性设置,我如何增加值通过PHP自定义属性?添加Magento产品属性
通过与product.create或product.update SOAP回答
$host = "127.0.0.1/magento/index.php"; //our online shop url
$client = new SoapClient('http://'.$host.'/api/soap/?wsdl'); //soap handle
$apiuser= "user"; //webservice user login
$apikey = "pw"; //webservice user pass
$sess_id= $client->login($apiuser, $apikey); //we do login
$attributeSets = $client->call($sess_id, 'product_attribute_set.list');
$set = current($attributeSets);
$newProductData = array(
'name' => 'name'
// websites - Array of website ids to which you want to assign a new product
, 'websites' => array(1) // array(1,2,3,...)
, 'short_description' => 'short'
, 'description' => 'description'
, 'status' => 'status'
, 'your_attributes' => $value
, 'your_attributes2' => $value
, 'your_attributes3' => $value
and so on
);
try {
$client->call($sess_id, 'product.create', array('simple', $set['set_id'], 'sku_of_product', $newProductData));
}
catch (Exception $e) { //while an error has occured
echo "==> Error: ".$e->getMessage(); //we print this
}
铪& GL:d
问候博提
,如果它已经
$newProductData = array('name' => 'name',
'your_attribute' => $value
,'your_attribute2' => $value
);
$proxy->call($sessionid, 'product.create', array('simple', $set['set_id'], sku, $newProductData));
存在,那么该产品将与您的自定义属性(S)来创建。
问候博提
感谢您的快速响应,你能告诉我如何所有的PHP文件必须看起来像。我在magento示例中看到$ proxy = new SoapClient('http:// magentohost/api/soap /?wsdl'); $ sessionId = $ proxy-> login('apiUser','apiKey'); $ attributeSets = $ proxy-> call($ sessionId,'product_attribute_set.list'); $ set = current($ attributeSets);最好的问候 –
是的,这对我来说工作得很好。它只适用于V1 soap api –
因为我发现与SOAP API V2更高版本做同样的事情在我寻找这个响应,我添加了我终于想出的解决方案。
对于V2 SOAP API,看起来我们需要将additional_attributes嵌套在multi_data或single_data层中?
看应用程序/代码/核心/法师/目录/型号/产品/原料药/ V2.php#256,我认为我们需要使用
$manufacturer = new stdClass();
$manufacturer->key = "manufacturer";
$manufacturer->value = "20";
$additionalAttrs['single_data'][] = $manufacturer;
或
$manufacturer = new stdClass();
$manufacturer->key = "manufacturer";
$manufacturer->value = "20";
$additionalAttrs['multi_data'][] = $manufacturer;
是使用像:
$productData = new stdClass();
$additionalAttrs = array();
// manufacturer from one of the two above^
$productData->name = $data['name'];
$productData->description = $data['description'];
$productData->short_description = $data['short_description'];
$productData->weight = 0;
$productData->status = 2; // 1 = active
$productData->visibility = 4; //visible in search/catalog
$productData->category_ids = $data['categories'];
$productData->price = $data['price'];
$productData->tax_class_id = 2; // 2=standard
$productData->additional_attributes = $additionalAttrs;
// Create new product
try {
$proxy->catalogProductCreate($sessionId, 'virtual', 9, $sku, $productData); // 9 is courses
} catch (SoapFault $e) {
print $e->getMessage(); //Internal Error. Please see log for details.
exit();
}
- 1. Magento的 - 添加全球产品属性
- 2. magento添加产品
- 3. Magento添加产品
- 4. Magento - 'samples_title'产品属性
- 5. Magento - 加载产品时属性不好?
- 6. 定制产品属性添加到Magento的事务性邮件
- 7. Magento - 已计算产品属性(属性)
- 8. 加入产品对比magento使用产品属性(类别)
- 9. 将属性添加到Magento中可配置产品的关联产品
- 10. Magento:为所有产品添加新属性
- 11. 如何将属性添加到Magento 2.1.x产品页面
- 12. 在产品报告网格中添加下拉属性Magento
- 13. 添加新产品图像类型(属性)在Magento
- 14. Magento:使用模块安装脚本添加产品属性
- 15. 如何将新字段添加到magento中的产品属性?
- 16. Magento的 - 添加媒体库属性产品平表
- 17. 为Magento产品添加另一个属性
- 18. 添加产品属性时出错
- 19. 在添加新产品时将值添加到magento下拉列表或多选产品属性
- 20. 添加WooCommerce产品属性而不会丢失现有产品
- 21. Prestashop - 当产品具有属性时无法添加产品(parsererror)
- 22. Magento - 产品页面上的Echo属性
- 23. 删除所有产品属性magento
- 24. 在list.phtml中显示产品属性 - Magento
- 25. 在magento中回显产品属性head.phtml
- 26. magento中的产品的多个属性
- 27. Magento可配置的产品属性
- 28. Magento预购产品有日期属性
- 29. Magento - 获得产品属性选项
- 30. Magento产品属性获取值
谢谢。唯一的问题是,我没有在我的服务器上激活肥皂。还有其他的方法吗? –