Skip to content

Instantly share code, notes, and snippets.

@kernusr
Created June 18, 2021 09:17
Show Gist options
  • Save kernusr/aa08660a7648d95016c2c1251199efe3 to your computer and use it in GitHub Desktop.
Save kernusr/aa08660a7648d95016c2c1251199efe3 to your computer and use it in GitHub Desktop.
Поиск дублей товаров в заказе в админке bitrix
if (typeof prods == 'undefined' || prods === null) {
let prods = {};
} else {
prods = {};
}
document.querySelectorAll('#sale_order_basketsale_order_view_product_table tbody[id*="sale_order_basketsale-order-basket-product-"] > tr:first-of-type').forEach(tr => {
let link = tr.querySelector('td:nth-of-type(2) > a');
if (!!link.href) {
let uri = new URL(link.href),
id = uri.searchParams.get('ID');
if (!!id) {
if (!prods[id]) {
prods[id] = {
'name': link.textContent,
'count': 0
}
}
prods[id].count += 1;
}
}
});
for (let prod in prods) {
if (prods.hasOwnProperty(prod)) {
if (prods[prod].count !== 1) {
console.log(prods[prod].name);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment