Skip to content

Instantly share code, notes, and snippets.

<?php
class Ip_Category_Model_Image
{
public function getResizedImage($image, $width, $height = null, $quality = 100)
{
if(!$image){return false;}
$imageUrl = Mage::getBaseDir('media').DS."catalog".DS."category".DS.$image;
if(!is_file($imageUrl)){return false;}
$imageResized = Mage::getBaseDir('media').DS."catalog".DS."category".DS."cache".DS."cat_resized".DS.$image;
<?php
$i++;
$_class = '';
if ($i % 4 == 0) $_class .= ' last-4-col';
if (($i - 1) % 4 == 0) $_class .= ' first-4-col';
if ($i % 3 == 0) $_class .= ' last-3-col';
if (($i - 1) % 3 == 0) $_class .= ' first-3-col';
$_class .= ($i % 2 == 0) ? ' even' : ' odd';
?>
<?xml version="1.0"?>
<config>
<modules>
<YOUR_MODULE>
<version>0.1.0</version>
</YOUR_MODULE>
</modules>
<frontend>
<layout>
<updates>
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference="head">
<action method="addCss"><stylesheet>css/YOURSTYLESHEET.css</stylesheet></action>
</reference>
</default>
</layout>
<script>
my_variable = '<?php echo $this->getBigTemplate();?>';
</script>
<?php
class Ip_Test_Model_Observer
{
public function implementOrderStatus(Varien_Event_Observer $observer)
{
$order = $observer->getEvent()->getOrder();
$orderItems = $order->getAllVisibleItems();
foreach ($orderItems as $item) {
/**
* Get collection size
*
* @return int
*/
public function getSize()
{
if (is_null($this->_totalRecords)) {
$sql = $this->getSelectCountSql();
$this->_totalRecords = $this->getConnection()->fetchOne($sql, $this->_bindParams);
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->joinField('category_id', 'catalog/category_product', 'category_id', 'product_id = entity_id', null, 'left');
$collection->addAttributeToFilter('category_id', array('null' => true));
$collection->addAttributeToFilter('status', 1);
$collection->addAttributeToSelect('*');
public function sendVendorNotification($po, $comment='')
{
$vendor = $po->getVendor();
$method = $vendor->getNewOrderNotifications();
if (!$method || $method=='0') {
return $this;
}