Subesh Pokhrel's Blog – Magento Development Tips,PHP,Google Maps
PHP & Magento Tips & Tutorials

Posts Tagged ‘ tricks ’

Have you ever wondered how Collection in Magento are built, containing array of individual Entity Objects of Magento? Collections are one of the most important data structure (if I am right) used in Magento. Most of the queries in Magento will result into collection, and then you will apply a foreach loop to access individual Entity Objects and their values. Today I came into a different situation where I had individual objects but needed to create a collection of those objects, so that I could return the collection from a function.

Continue reading “Creating Collection of Objects in Magento using a “Magical Class”:Varien_Data_Collection” »

  • Share/Bookmark

Here is a small snippet of code, yet useful, to get ordered items and its details. I’ve deviced this code a lot before and posted in Magento Commerce’s Forum as well. But felt like writting it again, so that I can have a quick refrence to it as well. Next thing, I’ve tried a lot to get all orders and their items details by single query, but have not yet come up with a solution. If you have any method of finding order and its details by a single query, then please do response. The code below first needs an order ID as it parameters to give order details.

Continue reading “Getting Ordered Items and their Detail from Order ID in Magento” »

  • Share/Bookmark

I had always thought of using Eclipse to debug Magento’s complex code flow, and tried number of times before. But without any success I had to abandon it, and thought was not applicable for Magento, remember the fox and the sour grapes :D I also tried using Trial Version of Zend Studio, but with no sucess.

Continue reading “Debugging Magento Using Eclipse PDT & Zend Debugger” »

  • Share/Bookmark

Query in Magento can be quite troublesome, if you are a starter..or non-starter. So I’ve tried to share some of the difficult queries using collection in Magento, so that it will be helpful to my blog readers and also a place where I can later refer to. Here is one of them, may not be dificult to all, but for me I had a very bad time initially, when I first started on Magento about a year ago. I had always thought to post on my blog, but when one of my collegue asked me about this I remembered and here’s the query.

Continue reading “Getting Customer’s Info Using Single Query Including Billing and Shipping Addresses” »

  • Share/Bookmark

In one of those time when you need to know what attributes of a product is used to make the current configurable product “configurable”, then here it goes :D Those configurable attributes are called as “Super Attributes”. Looking into the lower level at the Database level the attributes id are saved in the table “catalog_product_super_attribute”. In this configurable product’s Id and the attribute are saved. To get the attribute’s id you can directly write a custom query and fetch it. But to get its attribute code, attribute level you will then have to create an object attribute using the fetched id. But there is one shot option as well to do the same, in a managed Magento Way!

Continue reading “Getting Configurable Attributes (Super Attributes) of a Configurable Product” »

  • Share/Bookmark

Creating Multiselect type of product attribute whose source will be the Magento’s core tables is pretty simple. Just go to Manage Attributes and create a new one. But if you want the attribute’s source table be a custom table, then you need to think. Some times a case pops up that the store admin wants to save custom type of data for attribute’s option and you need to manage an image according to the attribute’s option. So for each option of the multiselect attribute option there is an image associated with it. In this case one of the method to sort out the things is to create a module that gives you an GUI to save option’s data in custom table and give option to upload the image along with it. Later, use this tables data as source of the attribute for product. The first part, saving the data in custom option is not our concern. You can go through this for doing those. But the main point of this article is to use the custom source as source of the muliselect attributes.

Continue reading “Creating Custom Sourced Multiselect Product Attribute” »

  • Share/Bookmark

Here are some methods of creating block by code in Magento. This type of code can be used directly in template, not need to create a layout file or add a child node inside already existing layout file. You can use this to echo a different type of block inside already loading block and template.

Continue reading “Creating Block From the Code in Magento” »

  • Share/Bookmark

Magento has a default option to show the overall rating’s summary of the product, which is shown in the product view page. This summary is based on all the review posted and approved for the particular product. In the summary the stars are shown accordingly, by taking the sum of all reviews and calculating the average rating. But I had a case where I needed to show those star ratings, only based on the last approved user ratings. What I did was just a small tweak in the Magento’s default working!

Continue reading “Getting Rescent Rating Summary of a product in Magento” »

  • Share/Bookmark

Magento gives an option to have different currency defined for each store. To get the product’s price based on the current store you can use the following code. It uses the default Magento’s helper class to do.

Continue reading “Getting the Product’s Price in current currency format of store” »

  • Share/Bookmark

Custom options are the options that can be added to any product, which gives an option for the user of the site to select what type of product they actually want. Here is a scenario where custom option can be helpful. If you have a product say ball and your stores sells plastic,rubber,glass balls. So you need to give the user to select what type of ball they actually want. Yes, you can do this by using configurable product as well, but why create an attribute for one product only! In this case custom option might be very helpful.

Continue reading “Getting all custom options of a product in Magento” »

  • Share/Bookmark

Search engine optimization by SEO Design Solutions