Inchoo's Magento Posts
Total Page:16
File Type:pdf, Size:1020Kb
September 8th, 2009 Published by: inchoo Inchoo's Magento Posts You're reading the 200th blog post edition of Inchoo's Magento e-book. It collects all of our blog posts on Magento. We want to thank everyone for staying with us so far and hope we will live to see 1000th blog post anniversary. :) Inchoo is an ecommerce design and development company specialized in building Magento online stores. Boost the speed of your Magento One of the drawbacks of Magento is currently its speed if default configuration is used. There are certain ways of making it run faster. The best one is to enable GZip compression by changing .htaccess file a little. You just need to uncomment part of the code. In my case, the speed increase was exactly 235%. Add custom structural block / reference in Magento | Inchoo If you already performed some Magento research, you will know that it is built on a fully modular model that gives great scalability and flexibility for your store. While creating a theme, you are provided with many content blocks that you can place in structural blocks. If you are not sure what they are, please read Designer’s Guide to Magento first. Magento provides few structural blocks by default and many content Step 1: Name the structural block blocks. This article tells what needs to be in place to create new Open the file layout/page.xml in your active theme folder. structural block. Inside you will find lines like: What are structural blocks? <block type="core/text_list" name="left" as="left"/> They are the parent blocks of content blocks and serve to <block type="core/text_list" name="content" as="content"/> <block type="core/text_list" name="right" as="right"/> position its content blocks within a store page context. Take a look at the image below. These structural blocks exist in the Let’s mimic this and add a new line somewhere inside the same forms of the header area, left column area, right column…etc. block tag. which serve to create the visual structure for a store page. Our goal is to create a new structural block called “newreference”. <block type="core/text_list" name="newreference" as="newreference"/> Good. Now we told Magento that new structural block exists with the name “newreference”. Magento still doesn’t know what to do with it. Step 2: Tell Magento where to place it We now need to point Magento where it should output this new structural block. Let’s go to template/page folder in our active theme folder. You will notice different layouts there. Let’s assume we want the new structural block to appear only on pages that use 2-column layout with right sidebar. In that case we should open 2columns-right.phtml file. Created using zinepal.com. Go online to create your own zines or read what others have already published. 1 September 8th, 2009 Published by: inchoo Let’s assume we wish the “newreference” block to be placed TRUNCATE `sales_order_entity_datetime`; below 2 columns, but above the footer. In this case, our TRUNCATE `sales_order_entity_decimal`; TRUNCATE `sales_order_entity_int`; updated file could look like this: TRUNCATE `sales_order_entity_text`; TRUNCATE `sales_order_entity_varchar`; <!-- start middle --> TRUNCATE `sales_order_int`; <div class="middle-container"> TRUNCATE `sales_order_text`; <div class="middle col-2-right-layout">< ?php getChildHtml('breadcrumbs') ?> TRUNCATE `sales_order_varchar`; <!-- start center --> TRUNCATE `sales_flat_quote`; <div id="main" class="col-main"><!-- start global messages --> TRUNCATE `sales_flat_quote_address`; < ?php getChildHtml('global_messages') ?> TRUNCATE `sales_flat_quote_address_item`; <!-- end global messages --> TRUNCATE `sales_flat_quote_item`; <!-- start content --> TRUNCATE `sales_flat_quote_item_option`; < ?php getChildHtml('content') ?> TRUNCATE `sales_flat_order_item`; <!-- end content --></div> TRUNCATE `sendfriend_log`; <!-- end center --> TRUNCATE `tag`; TRUNCATE `tag_relation`; <!-- start right --> TRUNCATE `tag_summary`; <div class="col-right side-col">< ?php getChildHtml('right') ?></div> TRUNCATE `wishlist`; <!-- end right --></div> TRUNCATE `log_quote`; <div>< ?php getChildHtml('newreference') ?></div> TRUNCATE `report_event`; </div> <!-- end middle --> ALTER TABLE `sales_order` AUTO_INCREMENT=1; ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1; Step 3: Populating structural block ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1; We have the block properly placed, but unfortunately nothing ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1; is new on the frontsite. Let’s populate the new block with ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1; something. We will put new products block there as an ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1; example. Go to appropriate layout XML file and add this block ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1; to appropriate place. ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1; ALTER TABLE `sales_order_int` AUTO_INCREMENT=1; <reference name="newreference"> ALTER TABLE `sales_order_text` AUTO_INCREMENT=1; <block type="catalog/product_new" name="home.product.new" ALTERtemplate="catalog/product/new.phtml" TABLE `sales_order_varchar` AUTO_INCREMENT=1; /> </reference> ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1; That’s it. I hope it will help someone ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1; ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1; There are 15 comments ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1; ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1; ALTER TABLE `tag` AUTO_INCREMENT=1; How to delete orders in Magento? | ALTER TABLE `tag_relation` AUTO_INCREMENT=1; ALTER TABLE `tag_summary` AUTO_INCREMENT=1; Inchoo ALTER TABLE `wishlist` AUTO_INCREMENT=1; You got a Magento project to develop, you created a Magento ALTER TABLE `log_quote` AUTO_INCREMENT=1; ALTER TABLE `report_event` AUTO_INCREMENT=1; theme, you placed initial products and categories and you also placed some test orders to see if Shipping and Payment -- reset customers methods work as expected. Everything seems to be cool and TRUNCATE `customer_address_entity`; the client wishes to launch the site. You launch it. When you TRUNCATE `customer_address_entity_datetime`; TRUNCATE `customer_address_entity_decimal`; enter the administration for the first time after the launch, you TRUNCATE `customer_address_entity_int`; will see all your test orders there. You know those should be TRUNCATE `customer_address_entity_text`; deleted. But how? TRUNCATE `customer_address_entity_varchar`; TRUNCATE `customer_entity`; If you try to delete orders in the backend, you will find out TRUNCATE `customer_entity_datetime`; that you can only set the status to “cancelled” and the order is TRUNCATE `customer_entity_decimal`; still there. Unfortunately, Magento doesn’t enable us to delete TRUNCATE `customer_entity_int`; those via administration, so you will not see any “Delete order” TRUNCATE `customer_entity_text`; button. This can be quite frustrating both to developers and TRUNCATE `customer_entity_varchar`; TRUNCATE `log_customer`; the merchants. People coming from an SAP world find the TRUNCATE `log_visitor`; inability to delete to have some merit but there should be a TRUNCATE `log_visitor_info`; status that removes the sales count from the reports i.e. sales, inventory, etc. ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1; ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1; SET FOREIGN_KEY_CHECKS=0; ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1; ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1; TRUNCATE `sales_order`; ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1; TRUNCATE `sales_order_datetime`; ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1; TRUNCATE `sales_order_decimal`; ALTER TABLE `customer_entity` AUTO_INCREMENT=1; TRUNCATE `sales_order_entity`; ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1; Created using zinepal.com. Go online to create your own zines or read what others have already published. 2 September 8th, 2009 Published by: inchoo ALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1; ?> ALTER TABLE `customer_entity_int` AUTO_INCREMENT=1; ALTER TABLE `customer_entity_text` AUTO_INCREMENT=1; < ?php if (!empty($result)): ?> ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1; <table id="relatedProductsList"> ALTER TABLE `log_customer` AUTO_INCREMENT=1; < ?php foreach ($result as $item): ?> ALTER TABLE `log_visitor` AUTO_INCREMENT=1; <tr class="productInfo"> ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1; <td><a href="<?php echo $storeUrl ?>/< ?php echo $item->url_key ?>< ?php echo $urlExt ?>">< ?php echo $item->name ?></a></td> <td>< ?php _e('Starting at') ?> $ < ?php echo floatval($item->price) ?></td> -- Reset all ID counters </tr> TRUNCATE `eav_entity_store`; < ?php endforeach; ?> ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1; </table> < ?php endif; ?> SET FOREIGN_KEY_CHECKS=1; Hope some of you find this useful. Especially those who refuse After you have it executed, the test orders will not be in the to use Web Services for connecting different systems. database any more. Keep in mind that this will delete ALL orders, in the database. So, you should execute this queries Download connect2MAGE WordPress plugin. immediately after launch. There are 6 comments connect2MAGE | WordPress plugin for Custom