Tôi đã thêm thuộc tính tùy chỉnh với mã "my_price" với "Loại đầu vào danh mục cho Chủ cửa hàng" được đặt thành "Giá" và gán nó cho "Mặc định" (chỉ) tập hợp thuộc tính.Magento API v2 và C# - đặt thuộc tính tùy chỉnh trong khi thêm sản phẩm
Bây giờ, tôi muốn đặt giá trị của nó, mỗi khi tôi thêm/cập nhật sản phẩm với API v2 (C#). Đây là mã không hoạt động (giá trị không được đặt):
// Connect & Auth:
Mage_Api_Model_Server_V2_HandlerPortTypeClient handler = new Mage_Api_Model_Server_V2_HandlerPortTypeClient();
session_id = handler.login(username, api_key);
// Getting attributes set:
catalogProductAttributeSetEntity[] attributeSets;
attributeSets = handler.catalogProductAttributeSetList(session_id);
attributeSet = attributeSets[0];
string attributeset_id = attributeSet.set_id.ToString();
// Adding product:
catalogProductCreateEntity mageProduct = new catalogProductCreateEntity();
// (...) setting product's name, sku, etc.
associativeEntity AdditionalAttributes = new associativeEntity();
AdditionalAttributes.key = "my_price";
AdditionalAttributes.value = "12,33";
associativeEntity[] AssociativeEntity = new associativeEntity[1];
AssociativeEntity[0] = AdditionalAttributes;
mageProduct.additional_attributes = AssociativeEntity;
handler.catalogProductCreate(session_id, "simple", attributeset_id, sku, mageProduct, "default");
Tôi đang làm gì sai?
làm thế nào về myPrice thay vì my_price? Bạn đã thử chưa? –
Tôi có cùng một vấn đề, bạn có tìm ra nó không. My catalogProductCrateEntity không bao giờ chuyển bất kỳ dữ liệu nào, –