0

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-index – Minesh Patel Mar 1 '16 at 6:48
2
  1. Make sure the product Status is Enabled (CSV file: status set to 1).
  2. Make sure the product Visibility is set to Catalog, Search (CSV file: visibility set to 4).
  3. Make sure the product is In Stock (CSV file: is_in_stock set to 1).
  4. Make sure the product has a quantity available (CSV file: qty is greater than 0).
  5. Make sure the product is in a category.
  6. Flush and update your cache in System > Cache Management.
  7. 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 it – Arunendra Mar 1 '16 at 7:04
  • Thank you for you reply. What you added in this code? – user2638108 Mar 1 '16 at 7:11
  • I have added : $product->setStoreId(1); please let me know if it's work for you – Arunendra Mar 1 '16 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 there – user2638108 Mar 1 '16 at 7:24
  • I have updated the answer plz check it – Arunendra Mar 1 '16 at 7:30
0

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();

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.