Monthly Archives: January 2012

Magento: Sort Newest products by ‘created date’and ‘new from date’

Well, through this write-up, I will let you know about an extension that enables the catalog to be sorted by the newest products. The extension is known as EWTechnologies_SortByNewest, and came to my notice when the toolbar was debugged for not displaying the pagination links. I had a deep look into it and was taken aback to find it overriding the default.

Mage_Catalog_Block_Product_List_Toolbar class but extending from Mage_Page_Block_Html_Pager.

The Mage_Eav_Model_Config class was completely overridden. This one was greatly changed in the Magneto’s later versions, so the override executes very old code. I found it very dangerous to keep albeit there weren’t any other visible detrimental effects. It is definitely not the best way to sprint obsolete code in any case.

I decided this feat does not need overriding as much as core code does; therefore I looked into it more deeply and came out with the solution that wasn’t too tough and did not entail overriding any core code per se.

Here is the code to sort/order product by both created date and new from date:-

$todayDate  = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);

$collection = Mage::getModel(‘catalog/product’)
->getCollection()
->addAttributeToFilter(‘news_from_date’, array(‘date’ => true, ‘to’ => $todayDate))
->addAttributeToFilter(‘news_to_date’, array(‘or’=> array(
0 => array(‘date’ => true, ‘from’ => $todayDate),
1 => array(‘is’ => new Zend_Db_Expr(‘null’)))
), ‘left’)
->addAttributeToSort(‘news_from_date’, ‘desc’)
->addAttributeToSort(‘created_at’, ‘desc’);

Conclusion

This approach functions on any Magento CE version more than 1.4 and PE and EE versions. The standalone problem arising out of it relates to a future Magento upgrade that upgrades created_at attribute, it gets quite easy to reapply the database edits for restoring functionality simpler than troubleshoot problems with core code overrides.

Magento Authority delivers quality Magento development services through its extensively experienced Magento professionals who are result-oriented.

Give Your Business and Products Facebook connection

Based on open source technology, Magento is one of the most-preferred CMS that allows for the better functionality and flexibility. It allows online merchants to better manage their e-commerce store. The open source technology helps in developing small & large business sites, and Magento works as one of the best platform for ecommerce development. This is an excellent option for all the online merchants, thanks to functional platform & user-friendliness. Since this CMS has been surfaced around the web it has been adopting & integrating new modules and extensions.
Now, it has come to support the latest “Want” and “Own” Facebook buttons that help drive social based traffic for all Magento online stores. As we all know that Facebook now works as a superb excellent marketing tool for your online store. And with the inclusion of these social buttons, the merchants can grow the strength of their business to great extent. These social buttons are easy to install on catalog and product pages. Plus, they come like a Magento core extension for Magento Community and Enterprise.
These buttons let customers express themselves better than ever by including items they “Want” on their Facebook pages for all to view as well as purchase them. Besides, there is also facility of adding Facebook profiles and Wish lists.
The “Own” button makes the marketing organic, as consumers show items they pride of owning. Your customers start acting as an extension of your marketing efforts since they can now answer questions, suggest products and write products’ reviews.
The first ecommerce platform that is; Magento allows incorporation for the “Want” and “Own” buttons through the Facebook Open Graph 2.0 extension.
So, give your business and your products the latest Facebook connection! For all these solutions, Magento Authority proves to be your best mate, as from here you can hire a Magento developer who is very adept at Magento customization of any module or extension.