magento search category name

Magento how to get category collection by name ? For example here we will get category by it name $category = Mage::getModel(“catalog/category”); $collection = $category->getCollection(); $collection->addAttributeToSelect(“*”); $collection->addFieldToFilter(“name”,array(“eq”=>’test’); The above code will fetch all category named “test”.

Read more

Magento get product by attribute

For example here we will product by it name   $collectionss = Mage::getModel(‘catalog/product’)->getCollection()->addAttributeToSelect(‘*’)->addUrlRewrite(); $collectionss->addFieldToFilter(array( array(‘attribute’=>’name’,’eq’=>’test’), )) Get Product By Id $_newProduct = Mage::getModel(‘catalog/product’)->load($id);

Read more

magento add product to cart

require_once ‘app/Mage.php’; Mage::app(“default”); Mage::getSingleton(“core/session”, array(“name” => “frontend”)); $session = Mage::getSingleton(“customer/session”); $userData=Mage::helper(‘customer’)->getCustomer()->getData(); $cart = Mage::getSingleton(‘checkout/cart’); $yourProId=7; $qty=2; $params = array( ‘product’ => $yourProId, ‘related_product’ => null, ‘qty’ => $qty ); $product = new Mage_Catalog_Model_Product(); $product->load($yourProId); $cart-> addProduct($product, $params); $cart->save(); Mage::getSingleton(‘checkout/session’)->setCartWasUpdated(true); $message = (‘Your cart has been updated successfully.’); Mage::getSingleton(‘checkout/session’)->addSuccess($message);

Read more