diff --git a/src/CoreShop/Bundle/ProductBundle/Resources/public/pimcore/js/specificprice/object/item.js b/src/CoreShop/Bundle/ProductBundle/Resources/public/pimcore/js/specificprice/object/item.js index 56ea47b088..554f033817 100644 --- a/src/CoreShop/Bundle/ProductBundle/Resources/public/pimcore/js/specificprice/object/item.js +++ b/src/CoreShop/Bundle/ProductBundle/Resources/public/pimcore/js/specificprice/object/item.js @@ -143,7 +143,6 @@ coreshop.product.specificprice.object.item = Class.create(coreshop.rules.item, { }, getSaveData: function () { - var saveData; if (!this.settingsForm.getForm()) { @@ -158,8 +157,7 @@ coreshop.product.specificprice.object.item = Class.create(coreshop.rules.item, { saveData['id'] = this.data.id; } - return saveData; - + return coreshop.helpers.convertDotNotationToObject(saveData); }, getId: function () { diff --git a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/helpers.js b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/helpers.js index d6df0ef18c..abc48f9ee4 100644 --- a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/helpers.js +++ b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/helpers.js @@ -35,3 +35,22 @@ coreshop.helpers.requestNicePathData = function (targets, responseHandler) { }.bind(this) }); }; + +coreshop.helpers.convertDotNotationToObject = function (data) { + var obj = {}; + + Object.keys(data).forEach(function (key) { //loop through the keys in the object + var val = data[key]; //grab the value of this key + var step = obj; //reference the object that holds the values + key.split(".").forEach(function (part, index, arr) { //split the parts and loop + if (index === arr.length - 1) { //If we are at the last index, than we set the value + step[part] = val; + } else if (step[part] === undefined) { //If we have not seen this key before, create an object + step[part] = {}; + } + step = step[part]; //Step up the object we are referencing + }); + }); + + return obj; +}; diff --git a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/item.js b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/item.js index dbce2f909d..7ad207eefa 100644 --- a/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/item.js +++ b/src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/resource/item.js @@ -144,21 +144,6 @@ coreshop.resource.item = Class.create({ }, convertDotNotationToObject: function (data) { - var obj = {}; - - Object.keys(data).forEach(function (key) { //loop through the keys in the object - var val = data[key]; //grab the value of this key - var step = obj; //reference the object that holds the values - key.split(".").forEach(function (part, index, arr) { //split the parts and loop - if (index === arr.length - 1) { //If we are at the last index, than we set the value - step[part] = val; - } else if (step[part] === undefined) { //If we have not seen this key before, create an object - step[part] = {}; - } - step = step[part]; //Step up the object we are referencing - }); - }); - - return obj; + return coreshop.helpers.convertDotNotationToObject(data); } });