I have uploaded product in CSV format. I set the product as enabled, stock as in_stock and quantity as 100 in CSV file, But the product is not showing in front end pages, But when I just open and save the product from admin panel the product is listing in front pages. Any help is appreciable. Thank you in advance
$product = Mage::getModel ( 'catalog/product' );
$product = Mage::getModel ( 'marketplace/product' )->setProductInfo( $product, $set, $type, $categoryIds, $sellerId, $groupId, $imagesPath );
$product->setAttributeSetId($attributeSetID);
$product->setTypeId('simple');
$product->setSellerId($sellerId);
$product->setGroupId($groupId);
$product->setCreatedAt(strtotime('now'));
$product->setName($productName);
$product->setManufacturer($barndOptionValue);
$product->setModel($ModelOptionValue);
$product->setProductcode($productCode);
$product->setRoomBudget($room_budget);
$product->setShortDescription($shortDescription);
$product->setDescription($Description);
$product->setSku($sku);
$product->setDimensionUnits($diamensionUnitValue);
$product->setLenghtWithoutPacking($diamensionLengthWithoutPacking);
$product->setWidthWithoutPacking($diamensionBreadthWithoutPacking);
$product->setHeightWithoutPacking($diamensionHeightWithoutPacking);
$product->setWeightUnit($weightUnitValue);
$product->setWeight($weightWithoutPacking);
$product->setWeightWithPacking($weightWithPacking);
$product->setRoom($roomIds);
$product->setMinimumOrderQuantity($minimumOrderQuantity);
$product->setOrderDispatchLeadTime($leadDispatchTime);
$product->setLengthWithPacking($dimensionWithPackingLenght);
$product->setWidthWithPacking($dimensionWithPackingBreadth);
$product->setHeightWithPacking($dimensionWithPackingHeight);
$product->setMsrp($msrp);
$product->setPrice($price);
$product->setShippingcostIncluded($shippingcostIncluded);
$product->setSellerProductcode($sellerProductcode);
$product->setVisibility(4); // catalog, search
$product->setStatus(1); // enbled
$product->setTaxClassId(0);
$product->setSellerShippingOption(17);
$product->setWebsiteIds(array(1));
$product->setData('group_price',$groupPrice);
$stockData = $product->getStockData();
$stockData['qty'] = $stock;
$stockData['is_in_stock'] = 1; //
$stockData['manage_stock'] = 1;
$stockData['use_config_manage_stock'] = 0;
$product->setStockData($stockData);
$product->save ();
-
might be indexing issue. try to re-indexMinesh Patel– Minesh Patel2016年03月01日 06:48:51 +00:00Commented Mar 1, 2016 at 6:48
2 Answers 2
- Make sure the product Status is Enabled (CSV file: status set to 1).
- Make sure the product Visibility is set to Catalog, Search (CSV file: visibility set to 4).
- Make sure the product is In Stock (CSV file: is_in_stock set to 1).
- Make sure the product has a quantity available (CSV file: qty is greater than 0).
- Make sure the product is in a category.
- Flush and update your cache in System> Cache Management.
- Reindex your data in System> Index Management.
Use below code :
<?
$product = Mage::getModel ( 'catalog/product' );
// $product = Mage::getModel ( 'marketplace/product' )->setProductInfo( $product, $set, $type, $categoryIds, $sellerId, $groupId, $imagesPath );
$product->setStoreId(1); // put store id
$product->setAttributeSetId($attributeSetID);
$product->setTypeId('simple');
$product->setSellerId($sellerId);
$product->setGroupId($groupId);
$product->setCreatedAt(strtotime('now'));
$product->setName($productName);
$product->setManufacturer($barndOptionValue);
$product->setModel($ModelOptionValue);
$product->setProductcode($productCode);
$product->setRoomBudget($room_budget);
$product->setShortDescription($shortDescription);
$product->setDescription($Description);
$product->setSku($sku);
$product->setDimensionUnits($diamensionUnitValue);
$product->setLenghtWithoutPacking($diamensionLengthWithoutPacking);
$product->setWidthWithoutPacking($diamensionBreadthWithoutPacking);
$product->setHeightWithoutPacking($diamensionHeightWithoutPacking);
$product->setWeightUnit($weightUnitValue);
$product->setWeight($weightWithoutPacking);
$product->setWeightWithPacking($weightWithPacking);
$product->setRoom($roomIds);
$product->setMinimumOrderQuantity($minimumOrderQuantity);
$product->setOrderDispatchLeadTime($leadDispatchTime);
$product->setLengthWithPacking($dimensionWithPackingLenght);
$product->setWidthWithPacking($dimensionWithPackingBreadth);
$product->setHeightWithPacking($dimensionWithPackingHeight);
$product->setMsrp($msrp);
$product->setPrice($price);
$product->setShippingcostIncluded($shippingcostIncluded);
$product->setSellerProductcode($sellerProductcode);
$product->setVisibility(4); // catalog, search
$product->setStatus(1); // enbled
$product->setTaxClassId(0);
$product->setSellerShippingOption(17);
$product->setWebsiteIds(array(1));
$product->setData('group_price',$groupPrice);
$product->setStockData(array(
'use_config_manage_stock' => 0, //'Use config settings' checkbox
'manage_stock'=>1, //manage stock
'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
'is_in_stock' => 1, //Stock Availability
'qty' => 999 //qty
)
);
$product->save ();
?>
-
I have updated the answer please check itArunendra– Arunendra2016年03月01日 07:04:35 +00:00Commented Mar 1, 2016 at 7:04
-
Thank you for you reply. What you added in this code?user2638108– user26381082016年03月01日 07:11:45 +00:00Commented Mar 1, 2016 at 7:11
-
I have added : $product->setStoreId(1); please let me know if it's work for youArunendra– Arunendra2016年03月01日 07:16:05 +00:00Commented Mar 1, 2016 at 7:16
-
Thank you, Product are listing in front end, but all are showing out of stock, but when I went to admin store and just save the product without making any changes the product will list as stock Availabile. have an idea. I have thousands of product so it is not possible to got to each product and save it from thereuser2638108– user26381082016年03月01日 07:24:24 +00:00Commented Mar 1, 2016 at 7:24
-
I have updated the answer plz check itArunendra– Arunendra2016年03月01日 07:30:23 +00:00Commented Mar 1, 2016 at 7:30
It looks like you are using a custom module and may be the save is not working properly can try to run this code at the end of your script ?
$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku)
->save();