Created
June 18, 2021 09:17
-
-
Save kernusr/aa08660a7648d95016c2c1251199efe3 to your computer and use it in GitHub Desktop.
Поиск дублей товаров в заказе в админке bitrix
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
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