1

I created a product using below script :

$product = Mage::getModel('catalog/product');
$product->setStoreId(1); 
$product->setWebsiteIds(array(1));
$product->setTypeId('simple');
$product->addData(array(
    'name' => 'Custom Name',
    'attribute_set_id' => $product->getDefaultAttributeSetId(), 
    'status' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED, 
    'visibility' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE,      // because I don't want to show on frontend 
    'weight' => 1,
    'sku' => 'custom123',
    'tax_class_id' => 0,
    'description' => 'desciption',
    'short_description' => 'short desciption',
    'stock_data' => array( 
        'manage_stock' => 1,
        'qty' => 999, 
        'is_in_stock' => 1
    ),
));
$product->save();

Above script create a row in database tablecatalog_product_entity but this product not showing in magento catalog product grid.

What do I do for showing product only in magento backend?

7
  • Try after reindexing
    – Manikandan
    May 6 '16 at 6:30
  • I am having same problem and its not working even after Reindexing. May 6 '16 at 6:33
  • use this sample product creation code and try whether it's displaying or not Refer this link - inchoo.net/magento/programming-magento/…
    – Manikandan
    May 6 '16 at 6:35
  • I have tried that also still it does not shown any product in GRID , although an product has been created in database. May 6 '16 at 6:39
  • i think the tax class or some thing not added correctly. i will update an answer try that. it may help you
    – Manikandan
    May 6 '16 at 6:46
0

By missing of some required field, product doesn't show up in the backend.

Your products are showing in the database, so try to do the following:

Go to catalog -> manage products. Your current url will look like:

[yoursite.com]/index.php/admin/catalog_product/index/key/[your_key]/

Change this url to [yoursite.com]/index.php/admin/catalog_product/edit/id/[product_id]/key/[your_key]/

You can find the product ids in the database. When you enter this url, you can edit the product and check/edit product attributes, like tax class, status, etc and make sure alle required attributes are set.

I have refer to this answer

8
  • I tried it before, but not working for me. May 6 '16 at 6:49
  • do you have the product id?
    – Manikandan
    May 6 '16 at 6:50
  • In database table catalog_product_entity I found a new row, when run above script. May 6 '16 at 6:52
  • did you get the product id from the database?
    – Manikandan
    May 6 '16 at 6:53
  • when I set this product visibilty as catalog, search then it showing in frontend search page, but not showing in backend grid. May 6 '16 at 6:53
0

problem is in line 'visibility' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE,

replace VISIBILITY_NOT_VISIBLE with VISIBILITY_BOTH

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.