Use the code given below to unsubscribe the email.
Mage::getModel('newsletter/subscriber')->loadByEmail($emailAddress)->unsubscribe();
To display contact number of magento store, we need to just copy and paste the code given below, where we want.
Mage::getStoreConfig('general/store_information/phone');
Magento adding downloadable product to cart by coding php
Posted by Ivan Prorskuryakov under Magento code
Probably you know it’s possible to add a product to the cart via querystring, but may be you prefer code a new module for your needs using Magento objects and methods.
So adding a simple product is easy:
...
$cart = Mage::getSingleton('checkout/cart');
// start ...
Here is how to get a collection of products best sold in a given date range (could be daily, monthly, weekly, etc…)
<ul>
<?php
$from = date("Y-m-d H:i:s", (time()-2592000));
$to = date("Y-m-d H:i:s", time());
$_productCollection = Mage::getResourceModel('reports/product_collection')
->addAttributeToSelect('*')
->addOrderedQty($from, $to, true)
->addAttributeToFilter('status', 1)
->setOrder('ordered_qty', 'desc')
->getSelect()->limit(10)->query();
foreach ( $_productCollection as $prod ...
Magento problem with Paypal Express and new customer registration [Solved]
Posted by Ivan Prorskuryakov under Magento code
You know there is this problem with Magento 1.4.* and 1.5.*, if you are using Paypal Express as payment method and your customer is a new one, when she/he complete the order this is without account association (Customer Group 0 ...
Magento adding you own custom RSS Feeds
Posted by Ivan Prorskuryakov under Magento code
You know you will need, before or after, to add your own custom RSS feeds to your Magento.
For example, I needed to create some custom RSS Feeds to list bestseller products by date (bestseller weekly, monthly, etc…)
How to do it? ...
If you have to export all or a part of your Magento products you can try this simple script which creates a products collection and writes a simple and custom XML file per product (but you can simply change it ...
Display All Magento Category On HomePage With Image
Sometime we need to display webstore categories with there images on homepage, its very simple to do it
just create a page call it hopepage.phtml then go to magento backend and call cms block.
Paste ...
Creating Session In Magento Frontend
Posted by Ivan Prorskuryakov under Magento code
For creating session in magento frontend we need to use getSingleton method and our session varible is set, please follow the example code given below.
$session = Mage::getSingleton("core/session", array("name"=>"frontend"));
$session->setData("sessionvarible", 8);
...
If we need to change or incress number of prodct in a coloum then we need to edit catalog.xml, By default Magento give 3 prodcut display
in coloum. The example given below with which we can change coloum count.
find the code ...
