crm.product.property.add
crm.product.property.add(fields)
Creates a new product property.
Parameters
Parameter | Description |
---|---|
fields | Set of fields - is a array ("field"=>"value"[, ...]), containing description of product properties. |
Example 1
// Creates properties of user type S:HTML function addPropertyExample(catalogId) { BX24.callMethod( "crm.product.property.add", { fields: { "ACTIVE": "Y", "IBLOCK_ID": catalogId, "NAME": "Property - HTML/text", "SORT": 500, "DEFAULT_VALUE": { "TYPE": "html", "TEXT": "<u><b>Tasty</b> \"<span style=\"color: #00a650;\">and ripe bananas</span>\"</u>" }, "USER_TYPE_SETTINGS": { "HEIGHT": 300 }, "USER_TYPE": "HTML", "PROPERTY_TYPE": "S" } }, function(result) { if(result.error()) console.error(result.error()); else console.dir(result.data()); } ); } function getCatalogId() { BX24.callMethod( "crm.catalog.list", {filter: {"ORIGINATOR_ID": "", "ORIGIN_ID": ""}}, function(result) { if(result.error()) { console.error(result.error()); } else { var catalogId = 0; if (result.total() !== 1) { catalogId = 0 } else { data = result.data(); if (data && data instanceof Array && typeof(data[0]) === "object" && data[0]["ID"]) { catalogId = parseInt(data[0]["ID"]); } } if (catalogId <= 0) { console.error("Fail to receive CRM product catalog ID"); } else { addPropertyExample(catalogId); } } } ); } function start() { getCatalogId(); } start();
Example 2
function addPropertyExample(catalogId) { BX24.callMethod( "crm.product.property.add", { fields: { "ACTIVE": "Y", "IBLOCK_ID": catalogId, "NAME": "Property - List", "SORT": 510, "MULTIPLE": "Y", "ROW_COUNT": 7, "LIST_TYPE": "L", "PROPERTY_TYPE": "L", "VALUES": { "n0": { "ID": "n0", "VALUE": "List value 1", "SORT": 100, "DEF": "Y" }, "n1": { "ID": "n1", "VALUE": "List value 2", "SORT": 200, "DEF": "N" }, "n2": { "ID": "n2", "VALUE": "List value 3", "SORT": 300, "DEF": "Y" }, "n3": { "ID": "n3", "VALUE": "List value 4", "SORT": 400, "DEF": "N" }, "n4": { "ID": "n4", "VALUE": "List value 5", "SORT": 500, "DEF": "N" }, "n5": { "ID": "n5", "VALUE": "List value 6", "SORT": 600, "DEF": "N" }, "n6": { "ID": "n6", "VALUE": "List value 7", "SORT": 700, "DEF": "N" }, "n7": { "ID": "n7", "VALUE": "List value 8", "SORT": 800, "DEF": "N" } } } }, function(result) { if(result.error()) console.error(result.error()); else console.dir(result.data()); } ); } function getCatalogId() { BX24.callMethod( "crm.catalog.list", {filter: {"ORIGINATOR_ID": "", "ORIGIN_ID": ""}}, function(result) { if(result.error()) { console.error(result.error()); } else { var catalogId = 0; if (result.total() !== 1) { catalogId = 0 } else { data = result.data(); if (data && data instanceof Array && typeof(data[0]) === "object" && data[0]["ID"]) { catalogId = parseInt(data[0]["ID"]); } } if (catalogId <= 0) { console.error("Fail to receive CRM product catalog ID"); } else { addPropertyExample(catalogId); } } } ); } function start() { getCatalogId(); } start();
© «Bitrix24», 2001-2024