How can I limit the results for the shortcodes?
I'm using:
[pto search=]
[pto related=]
Hi,
I'm trying to bring this mod on to the latest version of the plugin 1.0 but it seems the code changed.
I could replace the part in pto_product.php but couldn't find the case "atoz":
in pto_search.php.
And is there a limit possible too for [pto prices=] ?
Hi Marco,
My apologies the modification referred to pto.php not pto_search.php (corrected and line number updated above).
Sure - the same trick can be applied to limit prices. Extend the above modification as follows:
case "searchlimit":
global $pto_config_resultsPerPage;
$pto_config_resultsPerPage = $v;
break;
case "relatedlimit":
global $pto_config_relatedPerPage;
$pto_config_relatedPerPage = $v;
break;
case "pricelimit":
global $pto_config_pricePerPage;
$pto_config_pricePerPage = $v;
break;
case "atoz":
And then in pto_product.php look for the following code at line 280:
$sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."products` WHERE normalised_name = '".$wpdb->escape($pto_product)."' ORDER BY price";
...and REPLACE with;
$sql = "SELECT * FROM `".$pto_config_databaseTablePrefix."products` WHERE normalised_name = '".$wpdb->escape($pto_product)."' ORDER BY price";
global $pto_config_pricePerPage;
if (isset($pto_config_pricePerPage))
{
$sql .= " LIMIT ".$pto_config_pricePerPage;
}
Cheers,
David.
--
PriceTapestry.com
Hi Marco,
In order to preserve the existing default of 3 related products, in pto_product.php look for the following code at line 160:
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH name AGAINST ('".$wpdb->escape($product->name)."') AS relevance FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$where." GROUP BY name ORDER BY relevance DESC LIMIT 3";
...and REPLACE with:
global $pto_config_relatedPerPage;
if (!isset($pto_config_relatedPerPage)) $pto_config_relatedPerPage = 3;
$sql = "SELECT * , MIN( price ) AS minPrice, MAX( price ) AS maxPrice, COUNT( id ) AS numMerchants, MATCH name AGAINST ('".$wpdb->escape($product->name)."') AS relevance FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$where." GROUP BY name ORDER BY relevance DESC LIMIT ".$pto_config_relatedPerPage;
Finally, in pto.php look for the following code at line 550:
case "atoz":
...and REPLACE with:
case "searchlimit":
global $pto_config_resultsPerPage;
$pto_config_resultsPerPage = $v;
break;
case "relatedlimit":
global $pto_config_relatedPerPage;
$pto_config_relatedPerPage = $v;
break;
case "atoz":
With that in place, you can now use, for example:
[pto searchlimit="5" search="Widgets"]
[pto relatedlimit="2" related="Blue Widget"]
Cheers,
David.
--
PriceTapestry.com