Programmatically add Magento products to categories

后端 未结 7 1865
执念已碎
执念已碎 2020-12-24 14:31

I am using Magento 1.4.0.1. I have over 21000 simple products, each entered into a single category. There are hundreds of categories in my site. Some products belong in mult

7条回答
  •  独厮守ぢ
    2020-12-24 15:10

    Well I ended up doing this with the API for some reason of laziness. This adds all the visible products into the category with ID 146:

     1, "connection_timeout" => 120));
    
      // Can be added in Magento-Admin -> Web Services with role set to admin
    
      $sess_id= $client->login('apiuser', 'apikey');
    
      // Get the product list through SOAP
      $filters = array('visibility' => '4', 'status' => '1');
      $all_products=$client->call($sess_id, 'product.list', array($filters));
    
      // Now chuck them into category 146
    
      foreach($all_products as $product)
      {  //var_dump($product);
          echo $product['sku']."\n";
          $doit=$client->call($sess_id, 'category.assignProduct', array('146', $product['sku']));
      }
    ?>
    

提交回复
热议问题