Created
October 10, 2013 15:51
-
-
Save wmakeev/6920692 to your computer and use it in GitHub Desktop.
Получение списка товаров (частями)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Костыль | |
function getGoodsByUuids(goodsUuids) { | |
var goods = [], | |
step = 45, | |
context = new Moysklad.Context(); | |
goodsUuids = _.chain(goodsUuids).uniq().value(); | |
for (var i = 0, len = goodsUuids.length; i < len; i += step) { | |
var query = context(Moysklad.ObjectModel.Good).uuid(_.first(_.last(goodsUuids, len - i), step)); | |
goods = goods.concat(query.load().items) | |
} | |
if(goodsUuids.length != goods.length) throw 'Внутреннаяя ошибка! Кол-во полученных и запрошенных товаров отличается.'; | |
return goods; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment