के माध्यम से अतिरिक्त विशेषताओं के साथ एक उत्पाद कैसे बना सकता हूं!मैं मैपेंटो में साबुन/जावा
मैं उत्पाद सूची प्रबंधन करने के लिए Magento के सोप API उपयोग करना चाहते हैं, गुण आदि मैं निम्नलिखित विन्यास चल रहा हूँ: -
- Magento 1.6
- साबुन एपीआई WS-I अनुपालन
- मैक OSX शेर
- 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 = new AssociativeArray();
AssociativeEntity attr1 = new AssociativeEntity();
attr1.("attribute1_key";
attr1.("attribute1_value");
attributes.getComplexObjectArray().add(attr1);
AssociativeEntity attr2 = new AssociativeEntity();
attr2.("attribute2_key");
attr2.("attribute2_value");
attributes.getComplexObjectArray().add(attr2);
createEntity.setAdditionalAttributes(attributes);
return createEntity;
}
मुझे एहसास हुआ कि मैं Magento के "system.log
" के लिए लिखा कोई त्रुटि मिलती है।
2012-01-21T09:41:01+00:00 DEBUG (7): First parameter must either be an object or the name of an existing class/opt/website/magento/app/code/core/Mage/Catalog/Model/Product/Api/V2.php
मैं लाइन 265. पर "V2.php
" फ़ाइल में त्रुटि स्थानीय बनाना सकता है php.net प्रलेखन "property_exists()
" विधि केवल वस्तुओं में क्षेत्रों के लिए जाँच कर सकते हैं के अनुसार। वास्तव में "$productData
" चर के रूप में "additional_attributes
" नामक एक संपत्ति है जो कि प्रकार सरणी है। इसलिए इस कोड के निष्पादन से एक त्रुटि होगी।
इसके अलावा मैं ऑब्जेक्ट को "$productData
" ऑब्जेक्ट की संरचना को Magento के SOAP API V2 के उपयोग के माध्यम से पुन: उत्पन्न करने के बारे में नहीं जानता।
अगर मैं इस कोड ("foreach
" लूप) लाइन 270 में जांच करते हैं, यह इंगित करता है एक वस्तु ("$productData
") एक सरणी ("additional_attributes
") जो फिर से कुंजी/मान जोड़े का एक सेट को संपुटित करेगा पकड़े है कि वहाँ (अगर मैं सही हूं)
253 protected function _prepareDataForSave ($product, $productData)
254 {
255 if (property_exists($productData, 'website_ids') && is_array($productData->website_ids)) {
256 $product->setWebsiteIds($productData->website_ids);
257 }
258
259 Mage::log("debug1");
260 Mage::log(property_exists($productData, 'additional_attributes'));
261
262 Mage::log($productData);
263
264 if (property_exists($productData, 'additional_attributes')) {
265 if (property_exists($productData->additional_attributes, 'single_data')) {
266
267 Mage::log("---> single");
268 Mage::log($productData->additional_attributes);
269
270 foreach ($productData->additional_attributes->single_data as $_attribute) {
271 $_attrCode = $_attribute->key;
272 $productData->$_attrCode = $_attribute->value;
273 }
274 }
275 if (property_exists($productData->additional_attributes, 'multi_data')) {
276
277 Mage::log("---> multi");
278 Mage::log($productData->additional_attributes);
279
280 foreach ($productData->additional_attributes->multi_data as $_attribute) {
281 $_attrCode = $_attribute->key;
282 $productData->$_attrCode = $_attribute->value;
283 }
284 }
285
286 Mage::log("debugXXX");
287 unset($productData->additional_attributes);
288 }
289
290 Mage::log("debug2");
291
292 foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) {
293 $_attrCode = $attribute->getAttributeCode();
294 if ($this->_isAllowedAttribute($attribute) && (isset($productData->$_attrCode))) {
295 $product->setData(
296 ... etc ...
यह एक बग प्रतीत होता है। तो ये रहा मेरा प्रश्न।
क्या मैं इसे एक प्रोग्रामिंग समस्या कहने के लिए सही कह रहा हूं जिसे बग बेस में पोस्ट किया जाएगा? क्या इस मुद्दे को पाने का कोई तरीका है? क्या मैं उपरोक्त से php.code के हिस्सों को फिर से लिख सकता हूं ताकि उत्पाद की जानकारी को सही तरीके से उत्पादित करने के लिए मेरी जानकारी को पूरा किया जा सके?
अग्रिम
$productData
(
[name] => testname
[description] => testdescription
[short_description] => shorttestdescription
[weight] => 70
[status] => 1
[visibility] => 4
[price] => 359.0
[tax_class_id] => 2
[additional_attributes] => Array
(
[attribute1] => 999.0
[attribute2] => testcontent
)
)
SoapUI द्वारा उत्पन्न डबल्यूएसडीएल से CatalogProductCreate-कॉल में धन्यवाद:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">
<soapenv:Header/>
<soapenv:Body>
<urn:catalogProductCreateRequestParam>
<sessionId>?</sessionId>
<type>?</type>
<set>?</set>
<sku>?</sku>
<productData>
<!--Optional:-->
<categories>
<!--Zero or more repetitions:-->
<complexObjectArray>?</complexObjectArray>
</categories>
<!--Optional:-->
<websites>
<!--Zero or more repetitions:-->
<complexObjectArray>?</complexObjectArray>
</websites>
<!--Optional:-->
<name>?</name>
<!--Optional:-->
<description>?</description>
<!--Optional:-->
<short_description>?</short_description>
<!--Optional:-->
<weight>?</weight>
<!--Optional:-->
<status>?</status>
<!--Optional:-->
<url_key>?</url_key>
<!--Optional:-->
<url_path>?</url_path>
<!--Optional:-->
<visibility>?</visibility>
<!--Optional:-->
<category_ids>
<!--Zero or more repetitions:-->
<complexObjectArray>?</complexObjectArray>
</category_ids>
<!--Optional:-->
<website_ids>
<!--Zero or more repetitions:-->
<complexObjectArray>?</complexObjectArray>
</website_ids>
<!--Optional:-->
<has_options>?</has_options>
<!--Optional:-->
<gift_message_available>?</gift_message_available>
<!--Optional:-->
<price>?</price>
<!--Optional:-->
<special_price>?</special_price>
<!--Optional:-->
<special_from_date>?</special_from_date>
<!--Optional:-->
<special_to_date>?</special_to_date>
<!--Optional:-->
<tax_class_id>?</tax_class_id>
<!--Optional:-->
<tier_price>
<!--Zero or more repetitions:-->
<complexObjectArray>
<!--Optional:-->
<customer_group_id>?</customer_group_id>
<!--Optional:-->
<website>?</website>
<!--Optional:-->
<qty>?</qty>
<!--Optional:-->
<price>?</price>
</complexObjectArray>
</tier_price>
<!--Optional:-->
<meta_title>?</meta_title>
<!--Optional:-->
<meta_keyword>?</meta_keyword>
<!--Optional:-->
<meta_description>?</meta_description>
<!--Optional:-->
<custom_design>?</custom_design>
<!--Optional:-->
<custom_layout_update>?</custom_layout_update>
<!--Optional:-->
<options_container>?</options_container>
<!--Optional:-->
<additional_attributes>
<!--Zero or more repetitions:-->
<complexObjectArray>
<key>?</key>
<value>?</value>
</complexObjectArray>
</additional_attributes>
<!--Optional:-->
<stock_data>
<!--Optional:-->
<qty>?</qty>
<!--Optional:-->
<is_in_stock>?</is_in_stock>
<!--Optional:-->
<manage_stock>?</manage_stock>
<!--Optional:-->
<use_config_manage_stock>?</use_config_manage_stock>
<!--Optional:-->
<min_qty>?</min_qty>
<!--Optional:-->
<use_config_min_qty>?</use_config_min_qty>
<!--Optional:-->
<min_sale_qty>?</min_sale_qty>
<!--Optional:-->
<use_config_min_sale_qty>?</use_config_min_sale_qty>
<!--Optional:-->
<max_sale_qty>?</max_sale_qty>
<!--Optional:-->
<use_config_max_sale_qty>?</use_config_max_sale_qty>
<!--Optional:-->
<is_qty_decimal>?</is_qty_decimal>
<!--Optional:-->
<backorders>?</backorders>
<!--Optional:-->
<use_config_backorders>?</use_config_backorders>
<!--Optional:-->
<notify_stock_qty>?</notify_stock_qty>
<!--Optional:-->
<use_config_notify_stock_qty>?</use_config_notify_stock_qty>
</stock_data>
</productData>
<!--Optional:-->
<store>?</store>
</urn:catalogProductCreateRequestParam>
</soapenv:Body>
</soapenv:Envelope>
'product_data' का आउटपुट क्या है? यहाँ पेस्ट करें। –