Magento: Create Free Shipping Rule

In Admin panel:

  1. Create a new Shopping Cart Price Rule.
  2. On the conditions tab, specify your conditions.
  3. On the Actions tab, set ‘Free Delivery’ to something other than ‘No’
  4. Save rule.
  5. Enable Free Shipping shipping method in System > Configuration.
  6. Set Minimum Order Amount to something ridiculously high.
  7. Save configuration.
  8. Test your rule.

Install Magento over SSH

Installing the sample data (this has to be done first, if you want it)

wget http://www.magentocommerce.com/downloads/assets/1.9.0.0/magento-sample-data-1.9.0.0.tar.gz
tar -zxvf magento-sample-data-1.9.0.0.tar.gz
mv magento-sample-data-1.9.0.0/media/* magento/media/
mv magento-sample-data-1.9.0.0/magento_sample_data_for_1.9.0.0.sql magento/data.sql
chmod -R o+w media var
mysql -h DBHOST -u DBUSER -pDBPASS DBNAME < data.sql chmod o+w var var/.htaccess app/etc rm -rf magento/ magento-sample-data-1.9.0.0/ magento-1.9.0.0.tar.gz magento-sample-data-1.9.0.0.tar.gz data.sql

Installing Magento

wget http://www.magentocommerce.com/downloads/assets/1.9.1.0/magento-1.9.1.0.tar.gz
tar -zxvf magento-1.9.0.0.tar.gz
mv magento/* magento/.htaccess .
chmod -R o+w media var
chmod o+w app/etc
rm -rf magento/ magento-1.9.0.0.tar.gz

Five Minute Guide: Join data from two tables in one collection using filters

Let’s say you have related information in two separate tables in Magento, e.g. news articles and authors. You can get a collection of news items easily enough with:
Mage::getModel('news/articles')->getCollection()
But how can you get the author information in the same collection? Here’s where collection filters come in handy. They basically allow you to add joins to a collection.

In your Block class, instantiate the collection and call the filter, passing the author ID:

class News_Block_Article_List extends Mage_Core_Block_Template {

/**
* Get all articles associated with author
*
* @param $authorId
*/
public function getArticles( $authorId ) {
return Mage::getModel( 'news/articles' )->getCollection()->addAuthorFilter( $authorId );
}
}

Then define the addAuthorFilter() method in your Resource Model:


class News_Model_Resource_Article_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {

/**
* Filter news articles by author
* @param $authorId
*
* @return $this
*/
public function addAuthorFilter( $authorId ) {
$this ->addFilter( 'author_id', array( 'eq' => $authorId), 'public');

return $this;
}

/**
* Hook for operations before rendering filters
*/
protected function _renderFiltersBefore() {
if ( $this->getFilter( 'author_id' ) ) {
$this->getSelect()->join(
array( 'na' => $this->getTable( 'news/authors' ) ),
'main_table.author_id=na.id',
array( '*' )
);
}
}
}