Javascript modifikacija
1 naročnik
1 naročnik
Kupil sem en dodatek za Magento, ki pa ga moram malo prilagoditi. Sprememba je verjetno čisto enostavna, a meni ne potegne, ker v Javascriptu nisem ravno domač.
Gre se iskanje preko Javascripta, najprej se izbere kategorijo, nato podkategorijo in nato še atribute. Rabil bi, da sta kategorija in podkategorija določeni, ostalo se pa da naprej izbirati. Spodaj je original funkcija, ki to po mojem mnenju to dela.
function GYearSelected(){
var baseURL="";
//validate if main category is selected
var main_categoryid="";
main_categoryid=document.getElementById("main_category").options[document.getElementById("main_category").selectedIndex].id;
if(main_categoryid==-1)
{
//alert('Please Select Category ');
document.getElementById("error-block-div").innerHTML="<p class=error-msg>"+"Please enter category search settings"+"</p>";
return;
}
var subcategid="";
subcategid=document.getElementById("subcategory").options[document.getElementById("subcategory").selectedIndex].id;
if(subcategid==-1)
{
baseURL="<?php echo $this->getBaseUrl() ?>" + "catalogsearch/advanced/result/?name=&description=&short_description=&sku=&price%5Bfrom%5D=&price%5Bto%5D=&category="+main_categoryid;
top.location.href = baseURL;
return
}
if(document.getElementById("make").options[document.getElementById("make").selectedIndex].id==-1)
{
baseURL="<?php echo $this->getBaseUrl() ?>" + "catalogsearch/advanced/result/?name=&description=&short_description=&sku=&price%5Bfrom%5D=&price%5Bto%5D=&category="+subcategid;
top.location.href = baseURL;
return
}
var makeval="";
makeval=trim(document.getElementById("make").options[document.getElementById("make").selectedIndex].value);
if(document.getElementById("model").options[document.getElementById("model").selectedIndex].id==-1)
{
baseURL="<?php echo $this->getBaseUrl() ?>" + "catalogsearch/advanced/result/?name=&description=&short_description=&sku=&price%5Bfrom%5D=&price%5Bto%5D=&make="+makeval+"&category="+subcategid;
top.location.href = baseURL;
return
}
var modelval="";
modelval=trim(document.getElementById("model").options[document.getElementById("model").selectedIndex].value);
if(document.getElementById("year").options[document.getElementById("year").selectedIndex].id==-1)
{
baseURL="<?php echo $this->getBaseUrl() ?>" + "catalogsearch/advanced/result/?name=&description=&short_description=&sku=&price%5Bfrom%5D=&price%5Bto%5D=&make="+makeval+"&model="+modelval+"&category="+subcategid;
top.location.href = baseURL;
return
}
var yearval=trim(document.getElementById("year").options[document.getElementById("year").selectedIndex].value);
baseURL="<?php echo $this->getBaseUrl() ?>" + "catalogsearch/advanced/result/?name=&description=&short_description=&sku=&price%5Bfrom%5D=&price%5Bto%5D=&make="+makeval+"&model="+modelval+"&year="+yearval+"&category="+subcategid;
//submit URL
top.location.href = baseURL;
}
Poskusil sem že tako, da sem main_categoryid določil id kategorije pa ne dela. Kakšna ideja?