Engine23

Magento Ecommerce Strategy, Design & Development

Rewrite or Overload Mage_Sales_Model_Order

If you have ever needed to rewrite/overload a core magento Model.

Its actually pretty easy

Step 1: create the module instantiation file

app/etc/modules/Russellalbin_Sales.xml

<?xml version="1.0"?>
<config>
<modules>
<Indiebooker_Sales>
<active>true</active>
<codePool>local</codePool>
</Indiebooker_Sales>
</modules>
</config>

Read more

How to get the reviews for a product by customer

Here is how you can get a product reviewed by a customer in Magento

$storeId = Mage::app()->getStore()->getId();
$customer_reviews = Mage::getModel('review/review')
->getResourceCollection()
->addStoreFilter($storeId)
->addEntityFilter('product', $product_id)
->addFieldToFilter('customer_id', array('eq' =>$customer->getData('id')));
 

Read more

MySQL convert unix timestamp to datetime

UPDATE invoice
   SET invoice_date2 = FROM_UNIXTIME(invoice_date) WHERE invoice_date > 0;
UPDATE invoice
   SET estimated_date2 = FROM_UNIXTIME(estimated_date) WHERE estimated_date > 0;
UPDATE invoice
   SET completed_date2 = FROM_UNIXTIME(completed_date) WHERE completed_date > 0;
UPDATE lawn_contract
  SET lawn_contract_date2 = FROM_UNIXTIME(lawn_contract_date) WHERE lawn_contract_date > 0;
UPDATE tree_shrub
SET estimated_date2 = FROM_UNIXTIME(estimated_date) WHERE estimated_date > 0;
UPDATE lawn_contract
SET estimated_date2 = FROM_UNIXTIME(estimated_date) WHERE estimated_date > 0;

Remove index.php from Yii project URL


Step 1 - Create htaccess

Open notepad or any other text editor, paste the following code into it :
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
 
RewriteBase /donis

Read more

Yii getCommandBuilder() to get the select statement that is built

$model = BanksToSalespeople::model();

$addresses = array();

$criteria = $model->dbCriteria;

$criteria->with = "users";

$criteria->together = true;

$criteria->join ="LEFT JOIN users ON t.userID = users.id";

$criteria->select = 'email';

$criteria->condition = "t.bankID = '$bankID' AND users.email != ''";

// This is how to get the query that is built from the Yii magic command builder:

$query = $model->getCommandBuilder()->createFindCommand($model->getTableSchema(),$criteria)->getText();

ActiveDataProvider show all results

The magic is 'pagination'=>false

That will not paginate the results and show all of them.  Be aware that this may return a lot of them so make sure its what you want.

 

return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
'pagination'=>false,
));

Mac desktop appears to be zoomed in

If you own a mac and your son or daughter decides to play with the keyboard, you may find yourself with such an issue. 

My screen was zoomed in about 30% so I had to move my mouse to the corners to get the page to move to see the entire page.

Here is how you fix that:

Hold down the CTRL button and scroll down with your mouse.

Viola!  Zoom in or out depending on your situation.

How to sort products Magento

How to change the product position in the category product listing.

Sounds simple but most of people don’t know how to do it.

Magento allows you to order your products by name or by price when you’re surfing a category.

It also allows you to change the position when you’re sorting by default.

  1. Go to: Catalog -> Manage Categories.
  2. Select a Category.
  3. Select the Category Products tab.

Custom Module with image upload in wysiwyg

Magento add wysiwyg editor in custom module.

step-1
Go to following path and open Edit.php
app\code\local\Namespace\Modulename\Block\Adminhtml\Modulename

and Add this Function

 protected function _prepareLayout()
{
// Load Wysiwyg on demand and Prepare layout
if (Mage::getSingleton(‘cms/wysiwyg_config’)->isEnabled() && ($block = $this->getLayout()->getBlock(‘head’))) {
$block->setCanLoadTinyMce(true);
}
parent::_prepareLayout();
}

Read more