Skip to content

Instantly share code, notes, and snippets.

@neodigm
Created November 16, 2017 19:17
Show Gist options
  • Select an option

  • Save neodigm/7524b0dcadff32b7810353df9cf02aa4 to your computer and use it in GitHub Desktop.

Select an option

Save neodigm/7524b0dcadff32b7810353df9cf02aa4 to your computer and use it in GitHub Desktop.
Get product counts from categories (Left Navigation Audit) - recursive
(function() {
$("#main-content .sub-cat > a").each(function(){
$Ak = $(this);
if( $Ak.attr("href") !== "#"){
var sURI = $Ak.attr("href");
var sName = $Ak.text();
try {
var sID = $.ajax( { dataType: "html", type: "GET", url: sURI, async: false } );
var nPloc = sID.responseText.indexOf( "sizeTotalNumRecs" );
if( nPloc >= 1){
var sEl = sID.responseText.substring( nPloc, (nPloc + 40) );
sEl = sEl.substring( (sEl.indexOf("value=") + 6), (sEl.indexOf("value=") + 16) );
console.log( '"' + sName.replace(",", "") + '", "' + sURI + '", ' + sEl );
}
}
catch (e) {
console.log( "ERROR" );
}
}
return true;
});
return true;
} )();
@neodigm

neodigm commented Nov 16, 2017

Copy link
Copy Markdown
Author

Requires JQuery 2.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment