I have created a new product from Magento backend but it does not show up under relevant category or in the product page it self. i.e If I type the product url key it goes to a 404 page.
This is just a simple product and I checked the following,
Product enabled : Yes Visibility : Catalog, search Product Images : All good Quantity Available : 9999999 Stock Availability : In Stock Assign to a category : Yes (I even went to Manage Category to see product is under Category products and its there) Product in web sites : Assigned Cache : Cleared 10 X times Indexing : Done
I did one more thing I looked at app/code/core/Mage/Catalog/Model/Category.php and add following line in getProductCollection() function before the return $collection
var_dump($collection->getAllIds());
Then I went to the category page and I could see var_dump output all product IDs assign to that category but still new product I is was not there :(
This is really frustrating took my whole day and no luck, any ideas?
UPDATE :
Just found that I could manually navigate to the product page by http://my.host/catalog/product/view/id/881
But in the page it says "...this item is currently unavailable" just dig in to the code and to see why this message is showing and found that, $_product->isSaleable() returns false.
But I'm not sure weather that has something to with product is not visible on category and cannot navigate sing URL Key
Finally manage to fix the issue. I'll explain what I did to fix this because it might help someone else as well.
Like I said in my question I did my checklist. But $_product->isSaleable() was returning false.
So I had to dig in to the code and found that $_product->isSaleable() is set in Mage_CatalogInventory_Model_Stock_Status::assignProduct().
public function assignProduct(Mage_Catalog_Model_Product $product, $stockId = 1, $stockStatus = null) { if (is_null($stockStatus)) { $websiteId = $product->getStore()->getWebsiteId(); $status = $this->getProductStatus($product->getId(), $websiteId, $stockId); $stockStatus = isset($status[$product->getId()]) ? $status[$product->getId()] : null; } $product->setIsSalable($stockStatus); return $this; } Then I found that $this->getProductStatus(); returned an empty array, and the reason for that is there are no entries in cataloginventory_stock_status table for my new product.
This table is only get updated when Stock Status index was rebuilt, which was all Green and "Ready" in Magento admin, but not really ready :(.
So I ran shell/indexer.php --reindexall to manually re-build all my indexes, which also updated cataloginventory_stock_status table.
Finally I could see my products. Yey!!
@Kingshuk Deb - So you are correct it was indexing, but Magento admin said it was all good, which mislead me from the beginning.
No comments:
Post a Comment