jNice with Multiple Select

jNice is a very useful jQuery plugin which helps you to create some nice forms from the html inputs. Unfortunately it is missing the customizing for the multiple select input, file input and textarea. I have modified the jNice script in order to enable the styling for the multiple select input. In the near future I will update to make it work for the input and textarea elements also.  The example page for the updated script can be found at www.mage-contacts.com/jquery/jnice/ and also you can download the example as jnice_v11.zip. If you have questions regarding jNice you can give a feedback here.

The original site of jNice is at www.whitespace-creative.com/jquery/jnice/

Posted in jQuery | Tagged , | Leave a comment

Block class override

If you happen to install  Creare Mass Landscape Shipping Label  and  Simple Order export  free modules  you will have the nasty surprise that in the orders actions menu  will not show up Print landscape shipping labels .  This is due to the fact that both override Mage_Adminhtml_Block_Sales_Order_Grid

<global>
<blocks>
<adminhtml>
<rewrite>
<sales_order_grid>SLandsbek_SimpleOrderExport_Block_Sales_Order_Grid</sales_order_grid>
</rewrite>
</adminhtml>
</blocks>
<models>
<slandsbek_simpleorderexport>
<class>SLandsbek_SimpleOrderExport_Model</class>
</slandsbek_simpleorderexport>
</models>
</global>

<global>
<blocks>
<adminhtml>
<rewrite>
<sales_order_grid>Creare_MassLandscapeShippingLabel_Block_Sales_Order_Grid</sales_order_grid>
</rewrite>
<rewrite>
<sales_order_view>Creare_MassLandscapeShippingLabel_Block_View_Masslandscapeshippinglabel</sales_order_view>
</rewrite>
</adminhtml>
</blocks>
</global>

 

The fast solution is to modify SLandsbek_SimpleOrderExport_Block_Sales_Order_Grid  and  in function _prepareMassaction()

add  after parent::_prepareMassaction();  the followings:

$this->getMassactionBlock()->addItem(‘mass_landscape_shipping_label’, array(
‘label’=> Mage::helper(‘sales’)->__(‘Print Landscape Shipping Labels’),
‘url’ => $this->getUrl(‘creareadmin/masslandscapeshippinglabel/massLandscapeShippingLabel’),
));

 

 

Posted in Errors, Uncategorized | Leave a comment

Exception message: Invalid method Mage_CatalogSearch_Model_Query::loadByQueryText

In magento 1.6  this caused by overriding with an older model local  in /app/code/local/Mage/CatalogSearch/Model

Posted in Errors | Leave a comment

Error Source model “customer_entity/address_attribute_source_country” not found for attribute “country_id”

If you happen to encounter this error in magento 1.6 there is a chance that was caused by an upgrade from a previous version of magento.  Check eav_atribute table and change rows containing

customer_entity/address_attribute_source_country
customer_entity/address_attribute_source_region

to

customer/entity_address_attribute_source_country
customer/entity_address_attribute_source_region

Also if you check your error log for this error you might notice the cause:

Varien_Autoload::include(Mage/Customer/Entity/Model/Address/Attribute/Source/Country.php) [<a href='function.Varien-Autoload-include'>function.Varien-Autoload-include</a>]: failed to open stream: No such file or directory …

Posted in Errors | 1 Comment

How to get the newest products of magento current category

If you ever need listing the newest products of magento current category (or even of a category given by it’s Id, see the code comments)

<?php
$totalPerPage = ($this->show_total) ? $this->show_total : 9;
$visibility = array(
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                  );
 
// If you want to use a specific category load it by using this
// $cur_category=Mage::getModel('catalog/category')->load($category_id);
// Get current category
$cur_category = Mage::registry('current_category');
$storeId = Mage::app()->getStore()->getId();
$_productCollection = 
Mage::getResourceModel('catalog/product_collection')->setStoreId($storeId)
                              ->addAttributeToSelect('*')
			      ->addStoreFilter($storeId)
                              ->addCategoryFilter($cur_category)
                              ->addAttributeToFilter('visibility', $visibility)
                              ->setOrder('created_at', 'desc')
			      ->setPageSize($totalPerPage);
 
?>
Posted in Categories, Products | Tagged , , | Leave a comment

Get magento page current url

echo Mage::help('core/url')->getCurrentUrl();
Posted in Uncategorized | Tagged , | Leave a comment

Magento new products

New products is one of the useful feature required for a magento site. Below is a short example how to have this. You can call this in a cms page.

$totalPerPage = ($this->show_total) ? $this->show_total : 9;
$visibility = array(
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                  );
 
$storeId = Mage::app()->getStore()->getId();
 
$_productCollection = 
Mage::getResourceModel('catalog/product_collection')->setStoreId($storeId)
                              ->addAttributeToSelect('*')
			      ->addStoreFilter($storeId)
                              ->addAttributeToFilter('visibility', $visibility)
                              ->setOrder('created_at', 'desc')
			      ->setPageSize($totalPerPage);
Posted in Products | Tagged , | Leave a comment

Magento query filter by category and attribute

We know how to show up the products of a category in a cms page. But what if we wanna filter them by an attribute? Here is an example where $category_id is a given category ID, $currentPage the number of page you want to fetch the results from and $limit is for the number of results per page:

$visibility = array(
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                  );
$cur_category=Mage::getModel('catalog/category')->load($category_id);
$_productCollection= Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->getCollection()
                                                                        ->addAttributeToSelect('*')
                                                                        ->addAttributeToFilter('visibility', $visibility);
$_productCollection->addAttributeToFilter('color', $this->getRequest()->getParam('color'));
 $_productCollection->addCategoryFilter($cur_category);
 $_productCollection->setPage($currentPage,$limit);
Posted in Categories, Queries | Tagged , , , , | 3 Comments

Add featured category products to cms home page

If you have a category with products( like the featured products) you can  include them in a cms page calling the template block  the following way:

{{block type=”catalog/product_list” template=”catalog/product/list.phtml” category_id=”5″ column_count=”4″ }}

You have to change category_id 5 for your categeory ID.  Blocks are very useful for the home page and you can edit list.phtml to get rid of paging if itdoes not suit you.  With column_count you can set the number of columns used for listing. For a working example you can go check out http://www.mage-contacts.com/magento-1.4.2-sample/category-products-cms-page

 

 

 

 

Posted in Categories, Cms | Tagged , , | Leave a comment