ds3464 2014-04-01 22:33
浏览 31
已采纳

尝试按类别过滤大型商务搜索结果

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?

  • 写回答

1条回答 默认 最新

  • dqab0824 2014-05-05 22:41
    关注
    $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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 如何将下列的“无限压缩存储器”设计出来
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口