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

Author Archive

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

Reporting can be a very important part of the Module you might be developing for Mageneto. If you are showing your data in Grid that’s good, but it will be better if you add XLS file generation action on that grid, so that the site administrator can see the report in paper. And if you have in paper you can visualize more clearly than on screen.

Continue reading “Create and Download XLS Report file using Magento’s Core” »

  • 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

If you want to create a custom module in Magento that has something to do with storing data into a custom table and using that later, then this is just the right post you have bumped into! I will presume that you already know about Models in Magento, what are they and how you can create them. Also I will presume that you will also know the basic module structure in Magento.
You will have to place this in your config.xml

<global>
     <ymodel>
            <class>YNamespace_YModule_Model</class>
	     <resourceModel>quotes_mysql4</resourceModel>
     </ymodel>
<quotes_mysql4>
                <class>YNamespace_Ymodule_Model_Mymodel</class>
                <entities>
			<mymodel>
				<table>ymodel_ytable</table>
			</mymodel>
		</entities>
      </quotes_mysql4>
</global>

Continue reading “Using Custom Table for Custom Module in Magento” »

  • Share/Bookmark

Today, I had really a good chance to move Magento Shop from Development Enviournment to Product Enviornment. On that course I faced some big difficulty in moving the database. I already had the files and DB of the development enviornment, imporing DB was a PIA. I uploaded all the files, which was easy. And next thing I did was uploaded DB dumpped files to root of Magento. Then I logged into SSH and logged into MYSQL. Then Used the following commands to import the dumpped DB files. But first made the database say “magento”.

Continue reading “Moving Magento Shop from Development Enviornment to Production Enviornment or Production to Local” »

  • 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

Search engine optimization by SEO Design Solutions