0

I have create product programmatically but not showing in catalog product grid.
Here is code :

    $product = new Mage_Catalog_Model_Product();
    $product->setWebsiteIds(array(1));
    $product->setAttributeSetId(9);
    $product->setTypeId('simple');
    $product->setCreatedAt(strtotime('now'));
    $product->setName('custom name');
    $product->setSku('custom123');
    $product->setManufacturer('brand id');
    $product->setCategories(array('categories id'));
    $product->setOffer('custom offer');
    $product->setPrice('10');
    $product->setSpecialPrice('8');
    $product->setStatus(1);
    $product->setTaxClassId(0);
    $product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
    $product->setStockData(array(
            'manage_stock' => 1,
            'use_config_manage_stock' => 0,
            'is_in_stock' => 0,
            'qty' => 0
          ));
    $product->save();

Above script create a row in database table catalog_product_entity but this product not showing in magento catalog product grid. This product is showing in frontend and backend sales_order_create page. But didn't showing in catalog product grid.
Please someone suggest me how to show product in catalog product grid.

5
  • ale you sure that product is added to correct category? Have you done reindex and cache flush? Apr 5 '17 at 13:59
  • @KonradSiamro adding to category is not necessary and reindexing only needed for frontend. Not backend. Apr 5 '17 at 14:01
  • Also try to open any product from the grid then in the url put your product id which is not showing in grid and check what necessary fields you have not added. try to add those and save and check. Apr 5 '17 at 14:02
  • I have open any product then in the url put newly added product_id. No necessary field is remaining. But when save this product it showing in grid. What's problem ? Apr 5 '17 at 14:12
  • I think, it's because of you are not saving stock of that product.
    – Ishan Jain
    Apr 7 '17 at 4:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.