Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Created October 10, 2013 15:51
Show Gist options
  • Save wmakeev/6920692 to your computer and use it in GitHub Desktop.
Save wmakeev/6920692 to your computer and use it in GitHub Desktop.
Получение списка товаров (частями)
// Костыль
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