小编ste*_*ope的帖子

如何通过Soap/Java在Magento中创建具有其他属性的产品

美好的一天!

我想使用Magento的SOAP API来管理产品目录,属性等.我正在运行以下配置: -

  • Magento 1.6
  • Soap API WS-I合规性
  • Mac OSX Lion
  • Mamp 2.0.5

如果有人想要创建新产品,则需要设置产品对象的一些属性.以下代码将演示我执行此操作的方法:

    public int createProduct(DatabaseProduct product) {

        ArrayOfString categories = new ArrayOfString();
                categories.getComplexObjectArray().add(categoryID);
        createEntity.setCategoryIds(categories);

        CatalogProductCreateEntity createEntity = populateCreateOrUpdateEntity(product);

        CatalogProductCreateRequestParam param = new CatalogProductCreateRequestParam();
        param.setSessionId(sessionId);
        param.setSet(setId);
        param.setSku(product.getSku());
        param.setType("simple");
        param.setStore(storeId);
        param.setProductData(createEntity);

        CatalogProductCreateResponseParam response = service.catalogProductCreate(param);
        return response.getResult();
    }

    private CatalogProductCreateEntity populateCreateOrUpdateEntity(DatabaseProduct product) {

        CatalogProductCreateEntity createEntity = new CatalogProductCreateEntity();
        createEntity.setShortDescription(product.getDescription().substring(0, 20) + "...");
        createEntity.setDescription(product.getDescription());
        createEntity.setName(product.getName());
        createEntity.setPrice(String.valueOf(product.getPrice()));
        createEntity.setStatus("1"); //active
        createEntity.setVisibility("4"); //visible in search/catalog
        createEntity.setWeight("70"); //some value 
        createEntity.setTaxClassId("2"); //standard

            AssociativeArray attributes = …
Run Code Online (Sandbox Code Playgroud)

php java soap magento

11
推荐指数
3
解决办法
2万
查看次数

Magento - 在Lion下使用MAMP堆栈时,SOAP API响应不完整

我使用soapUI测试了Magento的SOAP API.我成功登录并获得了登录哈希.然后我尝试检索产品列表,这很好.

这是在使用最新版本的Apache,mySQL和PHP的Linux服务器上.

然后我创建了Magento和数据库的备份.我想使用MAMP堆栈在Lion服务器上创建测试环境.Magento备份似乎工作正常,但SOAP API没有.

我再次使用soapUI获取登录哈希并尝试检索所有产品.但现在回应似乎不完整:

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento">
<SOAP-ENV:Body>
<ns1:catalogProductListResponseParam>
<result>
<complexObjectArray>
<product_id>7167</product_id>
<sku>000140</sku>
... etc ...
<complexObjectArray>34</complexObjectArray>
</category_ids>
<website_ids>
<complexObjectArray>1</complexObjectArray>
</website_ids>
</complexObjectArray>
<complexObjectArray>
<product
Run Code Online (Sandbox Code Playgroud)

为什么Lion/MAMP下的反应不完整?

soap soapui magento

1
推荐指数
1
解决办法
3317
查看次数

标签 统计

magento ×2

soap ×2

java ×1

php ×1

soapui ×1