cancel
Showing results for 
Search instead for 
Did you mean: 

products not showing in admin

products not showing in admin

hi,

 

I've added some product with this code:

 

$product = Mage::getModel('catalog/product');
        $rand = rand(1, 9999);
        $product
            ->setTypeId('simple')
            ->setAttributeSetId(4) // default attribute set
            ->setSku('example_sku' . $rand) // generate a random SKU
            ->setWebsiteIDs(array(1))
            ->setName('Test Product #' . $rand) // add string attribute
            ->setShortDescription('Description') // add text attribute
 
            // set up prices
            ->setPrice(24.50)
            ->setSpecialPrice(19.99)
            ->setTaxClassId(0)    // Taxable Goods by default
            ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
            ;
        $product->setEnabled(1);
        $product->save();

I can see them inside the table catalog_product_entity, but they don't show up in the admin thou. I've also already re-indexed, and all the caches are disabled.

What's wrong?

 

Thanks a lot

1 REPLY

Re: products not showing in admin

Set current store to Admin before adding products.

 

Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

 

Tanel Raja