Question

My bigcommerce code for filtering begins like this:

for($x=1;$x<$count;$x++){
$filter = array('category' => 54, 'limit' => 200, 'page' => $x); 
$products = Bigcommerce::getProducts($filter);

This doesn't work quite right, and I'm not sure if it is meant to.

Here is the bigcommerce api in php.

Can anyone tell me the correct way to pull only the results that have a category id of 54 using $filter?

Was it helpful?

Solution

$filter = array("category" => 54, "limit" => 200); 
$products = Bigcommerce::getProducts($filter);
 foreach ($products as $product) {
     //do something with results
}

I am not sure about the page option you used but this is the code that I use to filter products by category id. It should work the same adding in the page as well. You can also use a variable for the category id something like $_POST['catid'] where 'catid' comes from html page or from url: category.html?catid=54. This is how I display products in my store when no subcategories exist for a certain category id it will use that cat id to find all the products in that category. In my for each loop it creates the html for the list of products. You can use $product->name, etc. to access the product resources available and use html that is sent back to your main page using java script. Let me know if you have any other questions I had a hard time finding any help on this when I went through it so I am more than happy to help if I can. I hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top