Magento: Overriding / Rewriting Mysql4 and Resource Eav Collection Class

Here is a tip to override/rewrite Mysql4 and Resource Eav collection class. I will only be including the config xml code. You can read more about Model Overriding over here: Magento: Model Controller Block Helper Override By Mysql4 Collection Class, I mean like the following class: Mage_Sales_Model_Mysql4_Order_Collection Overriding Mysql4 Collection Class <global> <models> <sales_mysql4> <rewrite> … Read more

Magento: Adding OR and AND query condition to collection

Here is a quick tip to add OR query and AND query to collection object. I am implementing this on product collection. Getting product collection // PRODUCT COLLECTION $collection = Mage::getModel('catalog/product')->getCollection(); Adding AND query condition Filtering collection to select only those products whose sku is like ‘ch’ AND status is equal to 1 (i.e. enabled … Read more

Magento: A small bug on module creator

Module Creator helps in building basic module structure in Magento. It can be used as a standalone application or a Magento module in the process of creating a new Magento module. You can download and find more about it here: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/custom_module_with_custom_database_table I found a small bug while working with a module created through Module Creator. … Read more

Magento: How to get product stock quantity & other stock information?

Here is a quick code to get any product’s stock information like quantity (qty), minimum quantity (min_qty), stock availability (is_in_stock), minimum and maximum sale quantity (min_sale_qty and max_sale_qty), etc. First load the product. Product can be loaded in different ways. Here are the two different ways to load any product in Magento:- 1. Load product … Read more

Magento: Show/Hide Demo Store Notice

A demo store is where there are products but the order done by customer is not processed. If your website is in development mode then it is better to enable demo store notice. Enabling demo store notice in Magento is very simple. You just need to select an option in configuration settings in admin panel. … Read more

Magento: Show/Hide website to search engines by adjusting robots meta tag

The Robots META Tag is meant to provide users who cannot upload or control the /robots.txt file at their websites, with a last chance to keep their content out of search engine indexes and services. <meta name="robots" content="robots-terms"> The content=”robots-terms” is a comma separated list used in the Robots META Tag that may contain one … Read more

Magento: How to get actual price and special price of a product?

Here is a quick and useful code on getting actual price and special price of any product in Magento. The actual price is the real price assigned to the product and special price is the price after any discount is applied to the product. Loading Product $_productId = 52; $_product = Mage::getModel('catalog/product')->load($_productId); Get Actual Price … Read more

Magento: How to get product rating and review?

Here is the code to get ratings and reviews for any particular product. /** * Getting reviews collection object */ $productId = $product->getId(); $reviews = Mage::getModel('review/review') ->getResourceCollection() ->addStoreFilter(Mage::app()->getStore()->getId()) ->addEntityFilter('product', $productId) ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED) ->setDateOrder() ->addRateVotes(); /** * Getting average of ratings/reviews */ $avg = 0; $ratings = array(); if (count($reviews) > 0) { foreach ($reviews->getItems() as $review) … Read more