相关疑难解决方法(0)

如何通过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万
查看次数

标签 统计

java ×1

magento ×1

php ×1

soap ×1