after importing products into magento they dont show up catalog
After i import the products into magento which appears to go smoothly no errors; the products aren't visible in the store. however if i go to any product and save(even without changing anything) it it is instantly available. Why are these products not开发者_如何转开发 visible right away...
Running the latest stable build.
Thanks
The best way to solve this problem programmatically is to
Import the product
Examine all the product's attributes via some custom code
Save the product
Examine all the product's attributes via some custom code
Compare the results of #2 and #4
Ensure your import process explicitly sets whatever attributes were missing in #2 but present in #4
Here's the snipping I'd use to examine the product attributes. Run this or something like it in a phtml template, custom controller, etc.
var_dump(
Mage::getModel('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('sku','SKUGOESHERE')
->getFirstItem()
->getData()
);
For anyone else who is having this problem: I solved it by making sure you set the websiteid
for the product. If you are using a custom script, remember to add the following:
$product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
Inspired from Alan Storm answer, but lower level.
- Start from an empty database. Dump it to an SQL file labelled original.sql
- Create manually one of your products.
- Check it is visible.
- Dump your database to a file labeled manual.sql
- Overwrite your database by importing original.sql
- Create a csv file to import the product you have chosen and import it.
- Dump your database to a file labeled automatic.sql
- Compare manual.sql and automatic.sql with each other. You should see where the problem relies.
Fixed it with dtcuk's solution. Please note:
setWebsiteIds(array(
Basically even if there is just 1 website id that you want to set, you would still have to pass an array with 1 website id.
Make sure that you have gone into the admin interface and under System>Index Management select all and choose "Reindex" from the drop-down on top right. Execute.
Also, refresh the caching under System>Cache Management and for good measure, delete all the files in var/cache.
If that doesn't fix it, report back for more suggestions.
I experienced the same problem. Here the website id is missing. Then it should work.
$newProduct = Mage::getModel('catalog/product')
->setAttributeSetId('9')
->setTypeId('simple')
->setStatus(1)
->setTaxClassId(2)
->setWebsiteIds(array(1))
->setVisibility(4)
->setSku($sku)
->setName($name)
->setDescription($description)
->setShortDescription($shortDescription)
->setPrice($price)
->save();
I've had the same thing and after a long troubleshooting I've found, that my CSV was missing one field: "_product_websites" with a value of "base" (same across all the items).
In my case the issue was fixed by switching to English language before doing the import.
Since the import file included some attribute labels in English, the import should be performed in while the same language is selected for the admin interface.
精彩评论