Monday 16 July 2012

product add wishlist



<?php $wishlist = Mage::getModel('wishlist/item')->load($_product->getId(),'product_id');
      if($wishlist->getId())
          //product is added
      echo "Added! - Product is in the wishlist!";
      else
          //add product to wishlist
      echo "<a href='".$this->helper('wishlist')->getAddUrl($_product) ."'>Add This?</a>";
  ;?>



link :- http://stackoverflow.com/questions/6740696/check-whether-a-product-is-in-the-wishlist-or-not

Magento product add programmatically


CID= Category ID
Name= Product name
sku = Product Sku
weight = Product Weight.


<?php $data=array("weight"=>"10","sku"=>"sku20","name"=>"productnew","description"=>"description","sdesc"=>"sdesc","price"=>"103","cid"=>"4"); ?>
<?php $newproduct = new Mage_Catalog_Model_Product();
$newproduct->setTypeId('simple');
$newproduct->setWeight($data['weight']);
$newproduct->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
$newproduct->setStatus(1);
$newproduct->setSku($data['sku']);
$newproduct->setTaxClassId(0);
$newproduct->setCategoryIds($data['cid']);

$newproduct->setWebsiteIDs(array(1));
$newproduct->setStoreIDs(array(1));
$newproduct->setStockData(array(
'is_in_stock' => 1,
'qty' => 199,
'manage_stock' => 1
));
$newproduct->setAttributeSetId(4);
$newproduct->setName($data['name']);
//$newproduct->setCategoryIds(array(3)); // array of categories it will relate to
$newproduct->setDescription($data['description']);
$newproduct->setShortDescription($data['sdesc']);
$newproduct->setPrice($data['price']);
//$newproduct->save();
?>
<?php
$fullImagePath="/opt/lampp/htdocs/wishlists/skin/frontend/default/default/images/a3.jpg";
$newproduct->setMediaGallery (array('images'=>array (), 'values'=>array ()));
$newproduct->addImageToMediaGallery ($fullImagePath, array ('image','small_image','thumbnail'), false, false);
//$newproduct->addImageToMediaGallery ($fullImagePath, array ('small_image'), false, false);
//$newproduct->addImageToMediaGallery ($fullImagePath, array ('thumbnail'), false, false);
$newproduct->save();
?>

Cart item remove


<?php
Mage::getSingleton('checkout/session')->clear();
foreach( Mage::getSingleton('checkout/session')->getQuote()->getItemsCollection() as $item ){
   Mage::getSingleton('checkout/cart')->removeItem( $item->getId() )->save();
}
?>



OR
<?php echo $this->getUrl('checkout/cart/delete', array('id' => 'item_id')); ?>