Go online to create your own zines or read what others have already published.. September 8th, 2009 Published by: inchooALTER TABLE `customer_entity_decimal` AUTO_INCREMENT=1; ALTER TABL
Trang 1September 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
blocks This article tells what needs to be in place to create new
structural block
What are structural blocks?
They are the parent blocks of content blocks and serve to
position its content blocks within a store page context Take
a look at the image below These structural blocks exist in the
forms of the header area, left column area, right column…etc
which serve to create the visual structure for a store page Our
goal is to create a new structural block called “newreference”
Step 1: Name the structural block
Open the file layout/page.xml in your active theme folder
Inside you will find lines like:
<block type="core/text_list" name="left" as="left"/>
<block type="core/text_list" name="content" as="content"/>
<block type="core/text_list" name="right" as="right"/>
Let’s mimic this and add a new line somewhere inside the sameblock tag
<block type="core/text_list" name="newreference" as="newreference"/>
Good Now we told Magento that new structural block existswith the name “newreference” Magento still doesn’t knowwhat to do with it
Step 2: Tell Magento where to place it
We now need to point Magento where it should output thisnew structural block Let’s go to template/page folder in ouractive 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 thatcase we should open 2columns-right.phtml file
www.besthosting4magento.com
Trang 2September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 2
Let’s assume we wish the “newreference” block to be placed
below 2 columns, but above the footer In this case, our
updated file could look like this:
<div class="col-right side-col">< ?php getChildHtml('right') ?></div>
<! end right ></div>
<div>< ?php getChildHtml('newreference') ?></div>
</div>
<! end middle >
Step 3: Populating structural block
We have the block properly placed, but unfortunately nothing
is new on the frontsite Let’s populate the new block with
something We will put new products block there as an
example Go to appropriate layout XML file and add this block
to appropriate place
<reference name="newreference">
<block type="catalog/product_new" name="home.product.new" template="catalog/product/new.phtml" />
</reference>
That’s it I hope it will help someone
There are 15 comments
How to delete orders in Magento? |
Inchoo
You got a Magento project to develop, you created a Magento
theme, you placed initial products and categories and you
also placed some test orders to see if Shipping and Payment
methods work as expected Everything seems to be cool and
the client wishes to launch the site You launch it When you
enter the administration for the first time after the launch, you
will see all your test orders there You know those should be
deleted But how?
If you try to delete orders in the backend, you will find out
that you can only set the status to “cancelled” and the order is
still there Unfortunately, Magento doesn’t enable us to delete
those via administration, so you will not see any “Delete order”
button This can be quite frustrating both to developers and
the merchants People coming from an SAP world find the
inability to delete to have some merit but there should be a
status that removes the sales count from the reports i.e sales,
ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1; ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1; ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
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; ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
reset customers TRUNCATE `customer_address_entity`;
ALTER TABLE `customer_address_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_address_entity_datetime` AUTO_INCREMENT=1; ALTER TABLE `customer_address_entity_decimal` AUTO_INCREMENT=1; ALTER TABLE `customer_address_entity_int` AUTO_INCREMENT=1; ALTER TABLE `customer_address_entity_text` AUTO_INCREMENT=1; ALTER TABLE `customer_address_entity_varchar` AUTO_INCREMENT=1; ALTER TABLE `customer_entity` AUTO_INCREMENT=1;
ALTER TABLE `customer_entity_datetime` AUTO_INCREMENT=1;
Trang 3September 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;
ALTER TABLE `customer_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `log_customer` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor` AUTO_INCREMENT=1;
ALTER TABLE `log_visitor_info` AUTO_INCREMENT=1;
Reset all ID counters
TRUNCATE `eav_entity_store`;
ALTER TABLE `eav_entity_store` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
After you have it executed, the test orders will not be in the
database any more Keep in mind that this will delete ALL
orders, in the database So, you should execute this queries
immediately after launch
connect2MAGE | WordPress plugin for
easy Magento database connection
Hi everyone I wrote this little plugin while working on one
of our projects If you know your way around WordPress
then you know what $wpdb variable stands for Imagine the
following scenario You have WordPress installation on one
database, Magento on another You know your way around
SQL You can always make new object based on WPDB class
inside your template files giving it database access parameters,
or you can use this plugin and use $MAGEDB the same way
you use $wpdb
Below is a little example of using $MAGEDB to connect to
Magento database and retrieve some products by reading id’s
from custom field of some post inside your WordPress
Place this code inside one of your templates, like single.php
<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>
</tr>
< ?php endforeach; ?>
</table>
< ?php endif; ?>
Hope some of you find this useful Especially those who refuse
to use Web Services for connecting different systems
Download connect2MAGE WordPress plugin
There are 6 comments Custom checkout cart - How to send email after successful checkout in Magento | Inchoo
Recently I have been working on a custom checkout page forone of our clients in Sweden I had some trouble figuring outhow to send default Magento order email with all of the orderinfo After an hour or so of studying Magento core code, here
is the solution on how to send email after successful order hasbeen made
Not sure how useful this alone will be for you, so I’ll throw alittle advice along the way When trying to figure how to reuseMagento code, separate some time to study the Model classeswith more detail Then “tapping into” and reusing some ofthem should be far more easier
Latest News RSS box in Magento using Zend_Feed_Rss | Inchoo
You would like to have a eCommerce power of Magento, butalso have a blog to empower your business? In this case,you probably know that Magento doesn’t have some articlemanager in the box Many clients seek for supplementarysolution like Wordpress to accomplish this goal Ok, so youcreated a blog on same or different domain and you wouldlike those articles to appear somewhere in Magento (probablysidebar) This article will explain how to do it
Let’s create a file called latest_news.phtml
in app/design/frontend/default/[your_theme]/template/
callouts/latest_news.phtmlNow we will create a PHP block that will display the list
of articles from RSS feed We will use Inchoo RSS fordemonstration purposes In your scenario, replace it with yourown valid RSS URL
< ?php $channel = new Zend_Feed_Rss('http://feeds.feedburner.com/Inchoo'); ?>
<div class="block block-latest-news">
<div class="block-title">
<h2>< ?php echo $this-> ('Latest News') ?></h2>
</div>
<div class="block-content">
Trang 4September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 4
<ol id="graybox-latest-news">
< ?php foreach ($channel as $item): ?>
<li><a href="<?php echo $item->link; ?>">< ?php echo $item->title; ?></a></li>
Now, we should decide where to place it I assume you already
know how Magento blocks and references work Let’s assume
you would like to place it in right column by default for whole
catalog In this case open your app/design/frontend/default/
[your_theme]/layout/catalog.xml file and under “default” tag
update “right” reference with something similar
That’s it You should be able to see the list of articles from RSS
feed with the URLs Hope this will help someone
Advanced search in Magento and how to
use it in your own way
It’s been a while since my last post I’ve been working on
Magento quite actively last two months I noticed this negative
trend in my blogging; more I know about Magento, the less
I write about it Some things just look so easy now, and they
start to feel like something I should not write about Anyhow…
time to share some wisdom with community
Our current client uses somewhat specific (don’t they all) store
set When I say specific, i don’t imply anything bad about it
One of the stand up features at this clients site is the advanced
search functionality One of the coolest features of the built in
advanced search is the possibility to search based on attributes
assigned to a product
To do the search by attributes, your attributes must have that
option turned on when created (or later, when editing an
attribute) In our case we had a client that wanted something
with all of the searchable fields on form
Some of you might say why not use the default and call it a day
Well, default one does not get very user friendly when large
number of custom added searchable attributes are added in
Magento admin interface Then the frontend search form gets
cluttered and users are easily to get confused
So in our example we would like to use the advanced search
and all of it’s behaviour and logic but to use it on somewhat
special link and to hide unnecessary fields Therefore, our
custom pages he would have only one input field on form and
the submit button How do we set this up? Well, all of the logic
and functionality is already there
What we need is to:
• use the http://somestore.domain/catalogsearch/partnumber as a link
• show only custom_partnumber field on the search formFirst, we have to see where does the /advanced come from.Lets open our template folder at
app\design\frontend\default\default\template
\catalogsearch\
there you will see the /advanced folder Make a copy of thatentire folder, in the same location, and name it to somethinglike /custom
Now your /custom folder should have 2 files: form.phtml andresult.phtml
Next in line is the /layout folder in our template You need
to open catalogsearch.xml file Go to line 64 Do you see the
<catalogsearch_advanced_index> tag there Make the copy of
it (including all of the content it hold with the closing tag also).Put the copy of that entire small chunk of code right below.Now rename all of the occurrences of “advanced” to “custom”there like on code below:
<catalogsearch_custom_index>
<!– Mage_Catalogsearch –>
<reference name=”root”>
<action method=”setTemplate”><template>page/2columns- right.phtml</template></action>
</reference>
<reference name=”head”>
<action method=”addItem”><type>js_css</ type><name>calendar/calendar-win2k-1.css</
name><params/><!–<if/
><condition>can_load_calendar_js</condition>–></ action>
<action method=”addItem”><type>js</ type><name>calendar/calendar.js</name><!–<params/
><if/><condition>can_load_calendar_js</condition>–
></action>
<action method=”addItem”><type>js</ type><name>calendar/lang/calendar-en.js</name><!–
<params/><if/><condition>can_load_calendar_js</ condition>–></action>
<action method=”addItem”><type>js</ type><name>calendar/calendar-setup.js</name><!–
<params/><if/><condition>can_load_calendar_js</ condition>–></action>
</reference>
<reference name=”content”>
Trang 5September 8th, 2009 Published by: inchoo
Do the same for <catalogsearch_advanced_result> tag
Now go to the app\code\core\Mage\CatalogSearch\Block
folder And make a copy of /Advanced folder naming
it /Custom Open /Custom/Form.php and replace
class name Mage_CatalogSearch_Block_Advanced_Form
with Mage_CatalogSearch_Block_Custom_Form, then
open /Custom/Result.php and replace class
name Mage_CatalogSearch_Block_Advanced_Result with
Mage_CatalogSearch_Block_Custom_Result
Inside Form.php there is getModel() function DO NOT
replace the Mage::getSingleton(’catalogsearch/advanced’);
with Mage::getSingleton(’catalogsearch/custom’); The point
is to use the default advanced search logic here Same goes for
getSearchModel() function inside Result.php file
Next in line, controllers We need to make
the copy of AdvancedController.php and name it
CustomController.php, then open it and replace the
class name Mage_CatalogSearch_AdvancedController with
Mage_CatalogSearch_CustomController
Inside this CustomController.php there is a function
called resultAction() You need to replace the ( …
Mage::getSingleton(’catalogsearch/advanced’) … ) string
‘catalogsearch/advanced’ with ‘catalogsearch/custom’ This is
the one telling the browser what page to open
Now if you open your url link in browser with /index.php/
catalogsearch/custom instead of /index.php/catalogsearch/
advanced you will see the same form there
And for the final task… As we said at the start, the point of all
this is to 1) get more custom link in url and 2) display only one
custom searchable attribute field in form Therefore, for the
last step we need to go to the template\catalogsearch\custom
folder and open form.phtml file
Inside that file, there is one foreach loop that goes like
<?php foreach ($this->getSearchableAttributes() as
$_attribute): ?>
All we need to do now is to place one if() condition
right below it If your custom attribute name (code) is
“my_custom_attribute” then your if() condition might look
And you are done Now you have somewhat more custom url,
and only one custom field displayed on that url
This might not be the best method of reusing already writtencode, however I hope it’s any eye opener to somewhat moreelegant aproach
customers would ideally buy instead of the product they’re
viewing They might be better quality, produce a higher profitmargin, be more popular, etc These appear on the productinfo page Related products appear in the product info page
as well, in the right column Related products are meant to
be purchased in addition to the item the customer is viewing.
Finally, Cross-sell items appear in the shopping cart When
a customer navigates to the shopping cart (this can happenautomatically after adding a product, or not), the cross-sellsblock displays a selection of items marked as cross-sells to theitems already in the cart They’re a bit like impulse buys – likemagazines and candy at the cash registers in grocery stores
Upsells
This is the example of the Up-sell Ideally, the visitor issupposed to analyze those products as they should be relevant
to the one that is just loaded
There are 2 comments File upload in Magento
Now, Magento already have frontend and admin part of fileupload option implemented in themes Since backend part isstill missing, understand that this still doesn’t work, however,
if you’re interested how it looks, read on
We are coding module of similar functionality for one of ourclients as we speak, but we have our fingers crossed to see thisoption in next Magento version!
Trang 6September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 6
Inchoo TV – Magento channel
Making use of Magento getSingleton
method
In one of my previous articles I showed you how to use
getModel and getData methods in Magento Although we
should not put those to methods at the same level, since I’d say
the getModel is a bit more higher Higher in sense, you first
use the geModel to create the instance of object then you use
getData to retrieve the data from that instance I have said it
before, and I’m saying it again; Magento is a great peace of
full OOP power of PHP It’s architecture is something not yet
widely seen in CMS solutions
One of the architectural goodies of Magento is it’s Singleton
design pattern In short, Singleton design pattern ensures a
class has only one instance Therefore one should provide a
global point of access to that single instance of a class
So why would you want to limit yourself to only one instance?
Let’s say you have an application that utilizes database
connection Why would you create multiple instance of the
same database connection object? What if you had references
to an object in multiple places in your application? Wouldn’t
you like to avoid the overhead of creating a new instance of
that object for each reference? Then there is the case where
you might want to pass the object’s state from one reference
to another rather than always starting from an initial state
Inside the Mage.php file of Magento system there is a
getSingleton method (function if you prefer) Since it’s
footprint is rather small, I’ll copy paste the code for you to see
it
First, notice the word static In PHP and in other OOP
languages keyword static stands for something like “this can
be called on non objects, directly from class” Now let me show
you the footprint of the getModel method
Do you notice the parameters inside the brackets? They are the
same for both of theme Where am I getting with this? Well,
I already showed you how to figure out the list of all of the
available parameters in one of my previous articles on my site
So all we need to do at this point is, play with those parameters
using getSingleton() method and observe the results
Most important thing you need to remember is that using
getSingleton you are calling already instantiated object So if
you get the empty array as a result, it means the object is
empty Only the blueprint is there, but nothing is loaded in it
We had the similar case using getModel(’catalog/product‘)
on some pages If we done var_dump or print_r we could
saw the return array was empty Then we had to use the load
method to load some data into our newly instantiated object
What I’m trying to say, you need to play with it
to get the feeling Some models will return data rich
objects some will return empty arrays If we were to do
Mage::getSingleton(’catalog/session) on view.phtml file wewould retrieve an array with some useful data in it Donot get confused with me mentioning the view.phmtl file,it’s just he file i like to use to test the code UsingMage::getSingleton(’core/session) would retrieve us somemore data You get the picture Test, test, test… What’s greatabout the whole thing is that naming in Magento is perfectlylogical so most of the time you will probably find stuff you need
in few minutes or so
Figuring out Magento object context
One of the problems working under the hood of the MagentoCMS is determining the context of $this If you are about
to do any advanced stuff with your template, besides layoutchanges, you need to get familiar with Magento’s objects(classes)
Let’s have a look at the /app/design/frontend/default/default/template/catalog/product/view.phtml file If youopen this file and execute var_dump($this) your browser willreturn empty page after a short period of delay By page I mean
on the product view page; the one you see when you click onMagetno product Experienced users will open PHP error logand notice the error message caused by var_dump() Errormessage:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 121374721 bytes)
I like using print_r() and var_dump(), mostly because so far
I had no positive experience using fancy debug or any otherdebugger with systems like Magento
Why is PHP throwing errors then? If you google out the
error PHP has thrown at you, you’ll see that PHP 5.2has memory limit Follow the link http://www.php.net/manual/en/ini.core.php#ini.memory-limit to see how andwhat exactly
Google search gave me some useful results trying to solve myproblems I found Krumo at http://krumo.sourceforge.net/.It’s a PHP debugging tool, replacement for print_r() andvar_dump() After setting up Krumo and running it onMagento it gave me exactly what I wanted It gave me theobject type of the dumped file; in this case it gave me objecttype of $this
If you’re using an IDE studio with code completion supportlike NuSphere PhpED, ZendStudio or NetBeans and youdecide to do something like $this-> you won’t get any methodslisted I haven’t yet seen the IDE that can perform this kind ofsmart logic and figure out the context of $this by it self.What you can do is use the information obtained
by krumo::dump($this) Performing krumo::dump($this)
on /app/design/frontend/default/default/template/catalog/product/view.phtml file will return object type,Mage_Catalog_Block_Product_View
Now if you do
Mage_Catalog_Block_Product_View::
your IDE supporting code completion will give you
a drop down of all the available methods, let’s saycanEmailToFriend();
Trang 7September 8th, 2009 Published by: inchoo
Mage_Catalog_Block_Product_View::canEmailToFriend();
Now all you need to do is to replace
Mage_Catalog_Block_Product_View with $this like
$this->canEmailToFriend();
And you’re done All of this may look like “why do I need this”
What you need it a smart IDE, one that can figure out the
context of $this by it self and call the methods accordingly No
IDE currently does that, if I’m not missing on something For
now I see no better solution to retrieve the object context of
$this across all those Magento files
If you need some help setting up Krumo with Magento
you can read my other, somewhat detailed article on
activecodeline.com
Hope this was useful for you
There are 2 comments
Get product review info (independent) of
review page
Here at Inchoo, we are working on a private project, that
should see daylight any time soon One of the requirements
we had is to show product review info on pages independent
of product review page Let’s say you wish to show review info
on home page for some of the products After few weeks with
working with Magento, one learns how to use the model stuff
directly from view files Although this might not be the “right”
way, it’s most definitely the fastest way (and I doubt most of
your clients would prefer any other , especially if it’s some
minor modification)
Simple random banner rotator in
Magento using static blocks
This is my first post here and I’ll write about my first challenge
regarding Magento since I came to work at Inchoo
Please note that you are not restricted only to images, you
could use text, video or whatever you want here, but I’ll focus
on images with links as title says.
In order to show this block, you should be familiar with
Magento layouts
Since that is out of scope for this article, I’ll show you how to
put it below the content on cms pages
Changing default category sort order in
Magento
Category toolbar has many options By default is shows how
many items are in the category, you can choose how many
products you wish to be displayed per page, you can change
the listing type (List or Grid) and you may choose Sort Order
This “Sort Order” can be confusing The default “Sort Order”
is “Best Value” What does it mean? How is the Best value
determined? Can we change the default sort order?
What is “Best Value” filed?
When you go to Category page in Magento administration, youwill see “Category Products” tab From there, you will see thelist of products that are associated to this category The lastcolumn in “Position” That is how “Best Value” is determined
So, best value is not something that is dynamically calculated.You can tailor it to your likings
How to change default Sort Order
The file you need to look at is: /app/code/core/Mage/Catalog/Block/Product/List/Toolbar.php Since we’ll modify it, make acopy to /app/code/local/Mage/Catalog/Block/Product/List/Toolbar.php
One there, you will notice this code at the beginning of the file:
$this->_availableOrder = array(
'position' => $this-> ('Best Value'), 'name' => $this-> ('Name'), 'price' => $this-> ('Price') );
Default order takes the first value available So, all you have to
do is to either:
• reorder it if you want to have a selection in the Toolbar or
• set only one value of choice if you will remove theselection from the toolbar
I hope this will help somebody
There are 4 comments
Couple of days ago we launched a new Magento project:Pebblehill Designs This site utilizes Magento features andturns it into a very powerful online catalog You won’t noticethe Shopping Cart or checkout process yet Even withoutthose, this site shows exactly what Pebblehill has to offer: themost popular styles of custom upholstered furniture
You can customize the furniture collection to express yourown unique style made with the highest quality materials andcraftsmanship available
Pebble Hill Designs’ parsons chairs are “American made” withpride in Georgia The quality speaks for itself Your productsare pre-assembled and ready for use when you receive them
Trang 8September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 8
The love and the passion for beautiful home interiors
translates into a high-quality product with a sophisticated
style manufactured in the USA Pebblehill Designs has
assembled some of the most popular styles of custom
upholstered furniture to offer to our customers All styles are
available in every fabric shown or you can provide your own
fabric You can customize the furniture collection to express
your own unique style made with the highest quality materials
and craftsmanship available
TeraFlex PLUS, another Magento +
Wordpress duo
After we launched TeraFlex Suspensions website few months
ago, we created a new similar website for Teraflex PLUS
Although the name is similar, this is not the same company
The primary goal of this site is to help Jeep owners to upgrade
their pets with parts and accessories for any type of adventure
The secondary goal is to create a Jeep enthusiast community
in Utah, USA and surroundings The site is powered by
Wordpress and Magento combination
Magento is a superb Shopping Cart, but it lacks some of the
CMS features Wordpress is a superb CMS, but it fails to
provide the needs for the eCommerce goals The combination
of these can create a very powerful website We present you
TeraFlex PLUS : Jeep Adventure Outfitters
http://www.teraflexplus.com/
Magento part of the site can be viewed if you click at Shop byVehicle or Shop by Brand tabs from the main menu, but youwill notice that some blocks seamlessly integrate between twosolutions
We developed this site as the Surgeworks team The designwas created by one of out top designers, Rafael Torales Wehope you enjoy it and feel free to post your comments
There are 6 comments The Best Shopping Cart :: Trend analysis
of osCommerce, Magento, ZenCart and CRE Loaded | Inchoo
If you try to ask this question on some forum or newsgroup,you will surely get many replies Everyone will present youhis favorite My first developed online store was created withstandard osCommerce platform After three or four projects,
I started to work with CRE Loaded and used it frequently foryears Although it was also an osCommerce fork, it had manyadvantages I switched to Magento™ early this year and this
is my final choice
Google™ Trends is a great tool to check some platformspopularity by comparing it to the competition For my shortanalysis, I compared:
As you can see, osCommerce still remains the most populareCommerce platform However, you can notice that this
Trang 9September 8th, 2009 Published by: inchoo
popularity is fading ZenCart is stable for the past two years
And my previous favorite, CRE Loaded (much better solution
than ZenCart in my opinion), is very low Its popularity is also
fading even after their team put great effort into a new website
and identity
Now, take a look at blue line My prediction is that sometime
in Q1 2009, Magento will become most popular eCommerce
platform It will surely kick osCommerce off the throne where
that fat duck was sitting for many years It was about time
First of all, let me inform you that this article is for those of
you who are just starting with Magento If you are a Magento
expert, you will probably know this Consider it just a reminder
for those who use Magento for first time There are three
common mistakes that most people do when they try to use
Magento for first time, so read this article and you won’t be
one of them.:)
• More experienced PHP developers will first read
Magento Designers Guide before they try to style
Magento, but others won’t and that’s the mistake
number two Since Magento has great theme fallback
system there is really no need to touch default theme
Although easiest way to make new theme for new
Magento is top copy the whole theme to a new folder,
don’t do that Copy only the files you will need: from /
design/frontend/default/default/ directory to /design/
frontend/default/YOUR_NEW_THEME directory Do
the same thing with /skin/frontend/default/default/
Congratulations, you have your own theme just like
that All that left is to apply new theme
(System->Configuration->Design) and you are ready to do with
your theme files whatever you want
• Third mistake is modifying Magento core files What files
are core ones? All what is in app/code/core folder If you
have a need to modify some of those ones, you just need
to duplicate that file in the same directory path to app/
code/local For example, if you need to modify the file
app/code/core/Mage/Checkout/Block/Success.php
copy it to
app/code/local/Mage/Checkout/Block/Success.php
and leave the core file intact This way your Magento will
be more bullet-proof to future updates
Custom CMS page layout in Magento |
Inchoo
Last week I had a request to add new custom layout
for few cms pages in one Magento shop It’s really
useful for different static pages of your shop First create
extension with only config file in it: app/code/local/Inchoo/
AdditionalCmsPageLayouts/etc/config.xml
Add your page/custom-static-page-1.phtml template file (or
copy some default one for start) and you’re done There is
also tutorial about this on Magento Wiki However i don’t likeapproach of duplicating and overriding Mage files from /local,
if it can be avoided, so i decided to write this small and usefulexample of adding or overriding default Magento settingsthrough separated config files And yes, Magento values can
be overridden this way Default layouts config can be found
in app/code/core/Mage/Cms/etc/config.xml along with usedxml code structure, so check it out Thank you for listening!
Drupal to Magento integration, simple link tweak with multilingual site
I see my coworker and friend Željko Prša made a nice little post
on Adding a new language in Magento so I figure I’ll jump with
a little Drupal to Magento integration trick concerning linkissues and multilingual sites Here is a piece of code you canuse in your Drupal templates to do the proper switching fromDrupal site to Magento while keeping the selected language ofsite Note, this tweak assumes you have the desired languagesetup on both Drupal and Magento side
This part goes to some of your Drupal theme file
Note the $storeView variable; GET _store holds the value
of code name of the view you assigned in Magento, while GET _from_store variable is used as helper to Magento inner
workings You can basically omit the other one Your links toShop from Drupal to Magento should now activate the properlanguage, the same one you have active on Drupal side
There are 1 comments Adding a new language in Magento
As anything in Magento adding a new language is somethingthat requires a certain procedure which we will explain rightnow and for future reference
• 3 Now go to: Configuration -> Current ConfigurationScope (Select your language from the dropdown) and onthe right side under “Locale options” choose the desiredlanguage
That’s it, now when you go to the frontend of the site, you’llnotice a dropdown menu allowing the language switching
Access denied in Magento admin
Some of you may encountered this problem You install newMagento extension through downloader, try to access itsconfiguration settings and Magento throws “Access denied”
page at you Although you’re administrator of the system
Trang 10September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 10
So what happened here? Magento just doesn’t have stored
privileges for this new extension
First just try to logout and login again If that doesn’t work,
you need to reset admin privileges
Navigate to System->Permissions->Roles and click
Administrators role
Check your Role Resources settings just in case, Resource
Access dropdown should be already set to All for
administrators
Without changing anything just click “Save Role” button, so
that Magento re-saves all permissions
You should be able to access your new extension now without
problems
There are 5 comments
If you worked with osCommerce, Zen Cart, CRE Loaded or anysimilar eCommerce platform before, you might find Magentodatabase structure quite confusing when you see it for the firsttime I advise you not to rush too much figuring out what
is what by glancing through database Try to spend first fewhours getting familiar with some background For purposes
of flexibility, the Magento database heavily utilizes an Attribute-Value (EAV) data model As is often the case, thecost of flexibility is complexity Is there something in Magentothat is simple from developers point of view?
Entity-Data manipulation in Magento is often more knowledgedemanding than that typical use of traditional relationaltables Therefore, an understanding of EAV principles andhow they have been modeled into Magento it is HIGHLYrecommended before making changes to the Magentodata or the Magento schema (Wikipedia: Entity-attribute-value_model) Varien has simplified the identification of EAVrelated tables with consistent naming conventions Core EAVtables are prefixed with “EAV_” Diagrams in this post contain
a section labeled “EAV” which displays Magento’s core EAVtables and thier relationships to non-EAV tables
Database diagrams and documents found in this post areintended to mirror the database schema as defined by Varien.Table relationships depicted in the diagrams represent onlythose relationships explicitly defined as Foreign Keys in theMagento database Additional informal/undiagrammed tablerelationships may also exist, so when modifying the schema
or directly manipulating data it is important to identify andevaluate possible changes to these tables as well (and thetables they relate to, and the tables they relate to…)
The author of Database Diagram is Gordon Goodwin, ITConsultant You can see his info in the PDF
There are 12 comments Magento + Net Framework, simple order preview app
For those of you who are into kinky stuff I made a simple,more of a proof of concept, application that sits in Widnowstaskbar and shows the order info in balloon popup Took melittle more than half of hour to get this working Almost forgothow great C# is
Trang 11September 8th, 2009 Published by: inchoo
Magento has this great feature, rss feed for orders You
can access it via link http://myshopsite/rss/order/new It
requires authentication, so you need to provide Magento user
and pass to access this link Idea I wanted to play around
was how to get this info in my windows app It’s really, really
simple Below is the screenshot of this little app for you to see
what I’m talking about
And here is the application it self simpleorderpreview and full
source code (Visual Studio 2008 Express C#, entire solution
project) acmnewproducts
When you un-archive files from simpleorderpreview there is
only one thing you need to do prior to running exe file You
need to open ACMNewProducts.exe.config and set username,
password and url of your own Magento shop That’s it Now
you can run the app
One click on Magento icon inside the taskbar executes
show order process, while double cliking the icon closes the
application
I will not go into the details in this post on how this works
Basicaly it’s simple XML parser Most important part is the
HTTP authentification, which you can see in code source code
Hope you find this usefull, something to play with
There are 4 comments
Associate simple product with custom
options in grouped product in Magento |
Inchoo
Does the title sound complicated? Grouped Products display
several products on one page For example – if you’re selling
chef’s knives and you have the same knife in four sizes, you can
make a grouped product to display all four sizes Customers
can select the size(s) they want and add to cart from this page
Another example would be a themed bedroom set – you can
create a grouped product and sell the sheets, comforter, and
pillow cases all from the same page
Technically, we create a simple products and after that agrouped products When we edit the grouped product, we willassociate simple products to it.It works very fine, but some ofyou might have issue if a simple product has custom options
If that’s the case, and if costum options are set as required(default way), the simple product will not be associative to thegrouped product Let’s see what needs to be changed in thatcase
On Magento site, there is a nice tutorial how to create agrouped product Please read it first to become familiar withthe process If you don’t have to assign simple products withcustom options to a grouped product, that tutorial will beenough
Manually create Google Sitemap in Magento | Inchoo
Most of you probably know this, but let’s define what thesitemaps are Sitemaps are a simple way for site creators togive search engines the information about pages on their sitethat are available for public Basically, those are just 1 or moreXML files that lists URLs for a site along with additional metainformatio about each URL (like last update, how often itchanges, its importance relevant to other pages) With this inmind, search engines can be more clever while crawling thesite Click here see how sitemap of this site looks like
You will hear the term Google Sitemap a lot, but XML Schemafor the Sitemap protocol is not related only to Google at all Itcan be used in many places, but the most important ones areGoogle Webmaster Tools and Yahoo! Site Explorer
Trang 12September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 12
How do we create Google Sitemap in Magento?
1 Sitemap File Configuration
First we need to create sitemap file in Magento This is
basically pointer to tell Magento where to create sitemap file
and how to name it Log in to Magento Administration and go
to:
Catalog -> Google Sitemap
Check to see if the sitemap file is already present Lets
assume we wish to create sitemap in the URL: http://
www.yourstore.com/sitemap/sitemap.xml
To do it successfully,
1 FTP to the server
2 create sitemap folder
3 chmod the folder to 777
On some servers, previous steps will not be required, but it is
better to create the file first so that Magento can edit it
Let’s go to Magento administration now and click on “Add
Sitemap” button Just insert the default values
After this step, we just told Magento where to create sitemap
file It is not yet created
2 Configure Sitemap
Sitemap can be configured from the interface System ->
Configuration -> Catalog->Google Sitemap If you are not sure
what does it all mean, check XML Tag definitions section from
“Sitemaps XML format” document
3 Create Sitemap Manually
Looks like Magento folks were thinking that sitemap should
only be created by a cron job Yes, it can be done that way
also Be sure to read Wiki article How to Set Up a Cron Job
to get familiar with it If you are looking for manual creation,
quit your search for “Create Sitemap” button You will not find
it But there is a workaround You can enter manual URL to
execute sitemap creation:
http://www.yourstore.com/index.php/admin/sitemap/
generate/sitemap_id/[ID of Sitemap from step 1]
Of course, replace the content with square brackets with actual
Sitemap ID
There are 9 comments
Observer pitfalls of building serious
modules in Magento
Unlike good old WordPress that “every kid in the block” knows
how to create a plugin for, Magento is a whole new system It
requires extensive knowledge of OOP, ORM’s, MVC, and few
other stuff This is why not “every kid in the block” can write a
module for Magento, and this is why I love it However, unlike
WordPress, Drupal and other community driven systems out
there who keep in mind backward compatibility things with
Magento things are a bit different
One of the things that caught my eye and made mewonder about the consequences is the Observer and overridefunctionality that probably most of the serious custom madeMagento modules will utilize Utilizing Observers enables you
to observe and execute some action inside the “customer workflow” or even some admin stuff Such functionality is heavilyknown is systems like WordPress and it’s called “hooks”.Besides hooking, another useful an very powerful featurewhich is actually related more to the OOP concept itself is theoverriding Personally i find the combination of observers andoverrides to be the coolest and most powerful stuff in Magentomodule development
So where is the issue? As of time of this writing, thelatest Magento version is 1.3.1 Let’s look at the previous
“major” release prior to that one, version 1.2.1.2 Here is
a prepareForCart method signature from app/code/core/Mage/Catalog/Model/Product/Type/Abstract.php (line 239,Magento version 1.2.1.2):
Notice the difference? Although this might not look like
“that big of a deal” suppose you had implemented overridefunctionality like
In the above code, we override the prepareForCart method to
to some custom stuff for us This peace of code would workperfectly fine in version 1.2.1.2, but when client decides toupgrade the shop to 1.3.1 or newer he would get the error like
To me, stuff like this is a serious downside towards buildingadvanced modules Changing core files and core functionalitycan have serious impact on custom made modules eachMagento upgrade Therefore, one should keep an eye open
on what modules he will throw into the shop Personally Iconsider online stores very serious and have strong feelingsabout each store owner having somewhat of dedicateddeveloper that will be in charge even for stuff like adding newmodules
Just consider the financial loss for a store owner of any moreserious web shop if he decides to download the and installmodule himself just to realize that for incompatibility reasonsthis new module made his shop fully nonfunctional
How to transfer large Magento database from live to development server and other way round
I have been involved in Magento development for almost ayear now God knows I had (and still have) my moments ofpain with it If you are in professional, everyday, PHPdevelopment that focuses mainly on Magento then your lifeprobably isn’t all flowers and bees Magento is extremely richeCommerce platform, but its main downside IMHO is its sizeand code complexity If you download Magento via SVN, youwill sound find out it has around 11 600 and more files This
is no small figure Transferring that much of files over theFTP can be a real night mare Luckily we have SSH and tarcommand to handle this really neat
But what about database Today I worked on database withmore than 20 000 products in store and with extremelylarge number of categories What seemed like easy database
Trang 13September 8th, 2009 Published by: inchoo
transfer from live site to local developer machine to do a test
and fix on few issues tunerd out to be an issue for itself
Without further delay, here is my favorite tool to handle all
database related work from now on: Navicat
Among my favorite features is the Data transfer Directly
moving one database to another among different MySQL
servers works like a charm I find yourself strangled among
often database recommended action I suggests you test the
trial version of this tool
Here are some screenshots of Navicat Data transfer in Action
There are 4 comments
Affiliates for all – Magento integration
Recently one of our clients needed and info on Affiliate module
for Magento When it comes to Magento, word “module” is
loosely related Sure, every module needs config files in order
to report it’s “connection” to Magento core Modules like this,
Affiliates for all, are modules I consider loosely related to core.They are in one or another way connected to Magento but theyare self standing, independent, applications
Installation of Affiliate module is a trivial task It mostlycomes down to extracting downloaded archive file to a webaccessible directory (to your server, hosting) and configuringthe config.inc file (For security reasons, try renamingthe config.inc to config.inc.php, plus changing the /lib/bootstrap.php on line 23 to include config.inc.php) Afterimporting affiliates.sql into the database our installation isdone
To configure Magento part, one needs to copy required filesform /carts directory of Affiliate module and then (turn offCache) go to System > Configuration and set the requiredoptions After that you can go back to your Affiliate ForAll application, upload some banners and set their url links
to point to your Magento shop When you test banner thelinks (click on one of them to get you to Magento store,then Magento store url should have a little GET variable
in url like ?ref=someNum) Now when you do the entirecheckout process, order info gets recorded to Affiliate For Allapplication
If you wish to play with Affiliate For All without installing it,you can check out the demo (just use “Admin” both for userand password)
There are 2 comments New Magento theme tutorial | Inchoo
There are many new Magento stores that are publishedeach day If you are with Magento for a longer time, youwill also notice that many of those look similar to default
or modern Magento theme Creating an totally unique andcustom one can be a difficult process, easpecially taking intoconsideration number of different interfaces we have This iswhy many Magento developers choose to use the CSS fromone of mendioned Magento themes that come with defaultinstallation and style those up This is not a bad choice at all
as it speeds up the process and those default themes are verygood But, for those of you who wish to make an extra effort,
we suggest that you to take a look at Magento Blank Theme for
a head start
Before you get to this point, be sure to read MagentoDesigner’s Guide, where the Magento design terminology isexplained in this PDF document
Blank Theme is a sample skeleton theme for Magento designerand a perfect way to start a new one Let’s be honest, we willrarely want to develop a totally new layout We wish the header
on the top, footer on the bottom We wish to have 1, 2 or 3columns, we wish to have boxes Blank Theme does just that:provides a layout, but without any heavy styling This makes
it excellent base ground for a new Magento project It doesn’tcome with default installation, so you will have to use MagentoConnect to get it
theme
Trang 14http://www.magentocommerce.com/extension/518/blank-September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 14
Magento community member Ross gave a good review
comment:
This is a great theme to use for wire-framing or as a base
for developing a custom theme! It looks like a lot of work has
gone in to slimming down the HTML and CSS, which makes
it much easier to work with compared to the default theme.
I particularly appreciate the well structured and commented
CSS The only things I would want different at this stage is
for the ‘callouts’ to be taken out (and removal of associated
media images), and for this theme to be included in the main
Magento download (I would even like it to be the ‘default’) 5
stars from me!
Take a sneak peak of how does product info page looks line
with no styling, but in finished layout I’m sure that the CSS
wizards will find this invaluable
There are 11 comments
Magento product view page analysis |
Inchoo
One of the most edited file in Magento is the template file
View.phtml file Reason for this is that a lot of clients would
like to rearrange it differently on their online stores Here is
the analysis of that file and the list of all the methods it uses
One thing to keep in mind, this document shows you the
View.phtml block file and shows you it’s inherited methods
All of the Magento block files have the similar inheritance
principle Therefore to find out the available methods all you
need to do is open up the extended (inherited) classes
If you are using some smart IDE solution like NetBeans 6.5
with PHP code completion support, you can simply do the
Mage_Catalog_Block_Product_View-> and press the Ctrl +
Space to get the dropdown list of all the available methods
If that’s not the case, then you will how to do the things the
manual way
Create a Color Switcher in Magento
Magento comes packed with a lot of options But no matterhow many options you put into some product you can nevercover all of them One of such options (for now) is a colorswitcher in Magento To be more precise, an image switcherbased on color selection
Recently I’ve made a screencast on my site on this subject,with somewhat different title The idea is to have a dropdownbox from which you choose a color and based on the colorselection product image changes All of this is to be based onsome simple javascript (in my case, jQuery)
Before we continue, you might want to see color switcher inaction We used this solution on our Kapitol Reef project.First you need to upload some images to your product andgive them some meaningful names like Red, Blue, Greendepending on your product color When I say give themname, I mean on label values Same goes for creating customattribute You create a dropdown selection box and create thesame amount of dropdown options as you have images, givingthem the same name Red, Green, Blue… and so on Here aresome images for you to see what I’m talking about:
Trang 15September 8th, 2009 Published by: inchoo
After this is done we go to the code part There are three things
you need to do here
Upload the jQuery and save it into the /js/jquery/jquery.js
One important note on jQuery; for some reason I had to use
jQuery 1.2.3 to get this example working Latest version 1.2.6
(as of time of this writing) did not work You can see the exact
error it gave me on my screencast
Now you need to modify /template/page/html/head.phtml
file to include the jQuery script (or any other if you can code
the same logic into it) and write down few lines of JS to
do the switching (you can download my version of file here
head.phtml)
And finaly, you need to modify the /template/catalog/
product/view/media.phtml file to grab all of the product
images and dump them into some div Here is my sample
(media.phtml) so just copy paste the code
And some additional screenshots for you to see final result
After some additional styling you can get some impressiveresults for this Hope you find it useful
You can see complete screencast at:
http://activecodeline.com/wp-content/uploads/videos/MagentoProductColorChooser.swf
There are 28 comments Magento’s Onepage Checkout in a nutshell
For the last two days I’ve been working on a custom checkoutpage for one of our clients Basicaly a page can be shown
in Magento using simple Core_Template type Basically allcode is set inside the phtml file so it can be shown on everypossible page or block, meaning it’s object independent, noinheritance Something you can call from with your layout fileslike
To complete my work, I had two mayor requirements Onewas to manage my way around programmable adding a simpleproducts to cart, plus their quantity and other was to docheckout with items in cart Checkout was to be made withpredefined payment method as well as shipping method Afterreviewing a lot of Magento’s code involved in checkout processand process of adding products to cart and so on I’ve puttogether what I see as the most short example one can use to
do a checkout with such predefined conditions
If you have such special requirements for your site below is thecode that you can place on whatever file you wish and include
it yout tempalte as block type core/template
Where ubmitCustomCheckout is the name of the submitbutton or submit input field To extract addresses you can usesomething like
Magento official documentation download
We were among a few of the studios to receive the early release
of the Magento documentation before it’s official release date
We broke the embargo ’cause we just didn’t have the heart
to keep it to our selves, we all now how painful it is to workwithout it
Trang 16September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 16
Designer's Guide to Magento PDF
download | Inchoo
After many developed CRE Loaded’s online stores and
watching Magento development progress for quite some time,
I decided it was time to use Magento with my next client My
starting point for development was official Designer’s guide
I’m the type of guy who likes to have documents nice&clean,
so I tried to print it but print was a mess That’s when I decided
to create PDF of the official documentation for easy print This
is probably the best starting tutorial for creating a fresh new
Magento template
I plan to write a short related tutorials in the days of 1st
Magento development project, so I invite you to subscribe to
RSS if you wish to be posted
Custom admin theme in Magento
As mentioned on Magento forums the easiest way to achieve
this is with overriding adminhtml config with your local
custom one and activate it as module
This is just a small example of different approach with Admin
Theme config option in admin panel, to show you how things
can be done in different ways in Magento
Follow directory structure, copy files to their place and you will
notice new “Admin Theme” option in
System->Configuration->General->Design (Default Config scope) Your theme goes
in app/design/adminhtml/default/yourthemename folder It
doesn’t need to be whole theme of course, just the files you’re
changing
Disabling wishlist functionality
If like many of the Magento store owners you find that some of
the built-in features are not useful to you or to your customers
you can always disable them via the admin interface buy
disabling their respective modules
Wishlist is not one of them
To remove all of the traces of the wishlist functionality you
need to do the following:
1 Go to the Admin interface (select the appropriate scope)
and under System -> Configuration -> Customers -> Whishlist
select “No” under the “Enabled” in the General options
This will remove all of the whishlist links in the magento blocks
as well as the whishlist itself
2 Just to make things perfect you should
check the (yourskinname)/template/catalog/product/view/
addto.phtml and remove the “pipe” character from that file so
that it doesn’t disturb the looks of your site
3 Finally, since you do not need Whishlist anymore it is wise to
disable it’s respective module output thru the admin interface
(Go to: System -> Configuration ->Advanced->Advanced and
set disable “Mage_Whishlist” )
That’s it Your whish is Magento’s command
There are 4 comments Magento Installation with SVN or Wget Unix command | Inchoo
Those of you who know what SVN is, feel free to skip thisarticle Those of you who are not familiar with SVN, this is
a must-read If you use standard FTP to upload all Magentofiles, you may find this process very time consuming Magento1.1.8 has over 6.700 files in over 2.200 folders FTPing cansometimes take few hours on some servers Let’s look atalternatives
Both alternatives require SSH access to the server I’m awarethat some low quality webhosting providers do not provideyou with SSH info immediately If you don’t have SSH info,ask webhosting support If they don’t give it to you, changewebhosting provider Make it a rule, you’ll make your lifemuch easier
Get yourself familiar with basic UNIX commands first
Alternative 1: SVN
In the Downloads tab on Magento website, you will notice SVNpage link:
http://www.magentocommerce.com/svnYou can see how short this page is You have 2 commandsyou can run at SVN You can chack latest work in progress oryou can checkout latest stable version If you are starting todevelop a real project, you will probably want a stable version.Let’s look at the original command:
svn checkout http://svn.magentocommerce.com/source/branches/1.1
This is probably not the exact command you wish to run onthe server It will place the files in trunk folder I will assumetwo things:
1 You will want the clean code
2 You will want to specify the folder where you wishMagento to be installed
If those are correct assumptions, you will want to run acommand similar to this one:
svn export force http://svn.magentocommerce.com/source/branches/1.1shop
• svn – This is the command
• export - The difference with checkout is that with anexport, you get a clean copy of the code, and none ofthe subversion metadata, so it can’t be used to svn up ormake further changes
• –force – you will overwrite all of the folders and files ifthey exist
• http://svn.magentocommerce.com/source/branches/1.1 - this is SVN URL Leave itintact
Trang 17September 8th, 2009 Published by: inchoo
• shop - the name of the folder you wish to place the files
into You may set the folders name to your likings
Read more about SVN at Wikipedia SVN Page and Subversion
official site
Alternative 2: Installing via wget
I will not be very descriptive here This alternative is very well
explained on Magento website in Wiki section:
http://www.magentocommerce.com/wiki/groups/227/
installing_magento_via_shell_ssh
Both scenarios will only place files You still need to run web
based installer afterward But, that is another story
There are 6 comments
Custom Transactional Emails
Since transactional emails are very important for the process
of online shopping you need to have them set up just the you
want them and the default templates just don’t cut it You
need your own logo, email data and custom verbiage to be
consistent with the image of your company
Here how it’s done :
1 Creating custom transactional e-mails via Admin
a) In the admin panel of your magento installation go to:
System->Transactional Emails
You’ll be presented with a list of default emails You’ll need
to create a custom email so the only way to avoid writing our
custom templates from scratch is to use the existing code of
the template
Hint: If you want to see the template before copying, first click
on the “Preview” button on the right
b) To create the new template click on the “Add new template”
above the “Transactional Emails” list This is the part where
Magento helps you with the option to load a deafult template
for you to customize Nice feature indeed
Once you have loaded the deafult template give it a unique
name under the “Template name” input field by adding a
prefix of your own but leaving the deafult name as well
Example: ” mysite :: New account “
That way you can easily spot them in the long list of default
and custom emails
Afterwards you can easily customize the verbiage and styling
within the “Template subject” and “Template content”
The “Template content” is the body of the message that the
user will recieve upon transaction so be sure to change the
E-mail, name of the company etc You’ll need to upload the logo
of your company in the images folder of the skin you’re using
Once you are done with editing, save the changes and repeat
the process for the rest of the email templates
2 Assigning the templates to different stores and storeviews
Assigning is the easiest part Just go to the System
> Configuration > Sales > Sales Emails and select the
corresponding template minding the configuration scope
After you’re done with setting your new templates save theconfiguration by clicking on the “Save config”
That’s it Wise thing to do now would be to check how theemails look when received so make a test purchase to verifyeverything is the way it should be
There are 3 comments Bestseller products in Magento
Bestseller or best selling product is one of the features peopletend to ask for when it comes to Magento™
There are multiple ways to implement this feature
In this example, I’m not using controller or model directories
at all; I’m going to show you how to implement this featureusing only one file: the View
Basically, what you need to do is to create the directory insideyour template directory and place the bestseller.phtml file in
it In my example, I’m using the custom-created directory /inchoo All of the screenshots provided here are based on thatdirectory structure
Adding this feature to your store is a matter of two simplesteps:
• copy bestseller-phtml file to your directory
• display the block on home page
To add a block to a home page, you simply log into theMagento, CMS > Manage Pages > Home Then add thefollowing to the content area:
{{block type=”core/template” template=”inchoo/bestseller.phtml”}}
Notice the type attribute I used core/template which meansyou can place this code anywhere in your site and it will work.Code does not inherit any collection objects from controllerssince it has none All that is necessary for the bestseller.phtml
to work is defined in that single file
One more thing: If you study the code in bestseller.phtml fileyou will see, at the very top of the file, the part that says: $this-
>show_total
Trang 18September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 18
If I were to write
{{block type=”core/template” show_total=”12″
template=”inchoo/bestseller.phtml”}}
in my home page, then $this would be assigned property
show_total with a value of 12
Therefore, the provided bestseller.phtml file provides the
option of setting the number of products you wish to see listed
Here is the bestseller.phtml packed in bestseller.zip
Hope you find this useful
There are 20 comments
Magento 1.2 is out with downloadable
products | Inchoo
Just at the dawn of 2008, Varien launched a new version
of Magento: 1.2 Upgrading previous Magento versions was
sometimes not an easy task since Varien used to change
standard function names which caused themes to break We
backup the site, made a copy, took a deep breath, expected the
worse, and… Nothing The upgrade went smoothly Wow,
that felt good
We were joking at the company today
Zeljko: You know what’s easy in Magento?
Branko: There is nothing easy in Magento!
Zeljko is an front end interface developer, while Branko is
a programmer Although creating Magento theme is a clear
process if you follow designer’s guide, programming is much
more complex Before this version, Magento upgrades used to
cause troubles Hope this is over
There is always a good practice NOT to update platform to
latest version immediately Even in this case this proved to
be valid Two days after version 1.2 came version 1.2.0.1 that
fixed some flaws Keep this in mind when you wish to upgrade
to newest version of the platform immediately after it appears
New version sorts some issues from Magento 1.1.x versions
and brings some highly requested features such as:
• Support for Downloadable Products (to see this newproduct type in action visit the Magento Demo Store Weadded an example of an MP3 product and an eBook )
• Added Layered Navigation to site search result page,with control on the attribute level to include or excludeattributes used on the search results page
• Improved site search to utilize MySQL fulltext search
• Added support for fixed-taxes on product level for suchtaxes as “State Environmental Fee” in the USA and
“WEEE/DEEE” in the EU
• Upgraded Zend Framework to the latest stable version1.7.2
• Added a Layered Navigation Cache for improvedperformance of large catalogs (currently in beta and isNOT recommended for production use)
If you need to upgrade existing Magento version through theMagento Connect Manager to 1.2.0.1, follow this steps:
• Do NOT use your live or production site We suggestmaking a copy of your site and upgrading that copy first
• Backup your index.php and htaccess files (if modified)
• Log into your Magento Connect Manager
• Select the ‘Setting’ tab
• Change the Preferred State to ‘Stable’, and save settings
• For the Mage_All_Latest package select upgrade
• Click on the ‘Commit Changes’ button The upgradeshould start
• After upgrade is complete click on the ‘Refresh’ button
• Copy your original index.php and htaccess files back (ifneeded)
• Log into your admin and rebuild search index
• You should now have Magento 1.2.0 installed
Happy Magentizing
There are 1 comments Listing out products on sale in Magento | Inchoo
One of my recent articles was on the subject of sorting “OnSale” product in Magento The following is a cleaner and moreadvanced look at how—with few tricks and smart moves—youcan reuse existing Magento code and modify it to suit yourneeds
Product can be “on sale” in two ways:
1 when an item has a special price assigned to it on theindividual level, or
2 when a special promotion “covers” the item
It is important to remember that you don’t have to set up thespecial price on each product to get it to be on sale; you can
Trang 19September 8th, 2009 Published by: inchoo
simply create a promotion rule and say something like “Set all
the products in Category X to be on sale.”
I provided few screenshots at the bottom of this article to
provide a closer look at what I’m talking about I will not go
into too much details here since this is a bit more advanced
HOW TO, but here is the process in a nutshell:
First, create a copy of /catalog/product/list.phtml file
and name it onsale_list.phtml Here is my version of
onsale_list.phtml file
Second, “activate” this new file There are few ways you can do
this Let’s say you wish to assign this onsale_list.phtml on one
of our categories, named “On Sale,” for instance
We then go to Categories > Manage Categories > On Sale…
select Custom design and under Custom layout update, place
the following:
product_list_toolbar
If you now go to your category On Sale, it should only show
products you have assigned to category “On sale” that have a
special price set to them
If you now wish to apply Promotion rules to entire “On sale”
category, then you simply assign a rule to one item, and all
the items assigned to the same “On sale” category (covered by
promotion rules) will be automatically listed in the grid
Basically, the magic is in one simple IF statement
< ?php if(>special_price !== null) or
($_product->_rule_price !== null)): ?>
for each block that lists products
Check out the screenshots, they explain a lot
Hope you find a way to try this out Feel free to provide somefeedback or additional suggestions
There are 3 comments Magento
After many weeks of work, our 1st Magento project hitthe Web: TeraFlex Suspensions As the purpose of the site
Trang 20September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 20
in not primarily selling, but also branding and community
development, we decided to use Wordpress and Magento
combination to accomplish the client’s goals
The Magento portion is visible at http://www.teraflex.biz/
products/ We created an original and custom theme from
scratch since we did not want it to look like the default one or to
have a feel similar to the default one It was not an easy task as
the learning curve for Magento template system is quite steep
compared to other solutions However, it is worth the time
We added featured products to products page, the lightbox to
products info page, and numerous styles that made this store
quite unique
Wordpress
All the menu elements outside Products tab are run by
Wordpress We have stuff like:
All of these elements turn Wordpress into a feature-rich CMS
suitable for larger projects
How do you like the new site? Feel free to post a comment
There are 4 comments
Place Contact form in CMS Page in
Magento | Inchoo
As you know, Magento has a built-in contact form that can
be used for general contacts That form isn’t part of any CMS
page, you cannot edit some introduction text, you cannot
add phone numbers administration, and you cannot see the
breadcrumbs If you wish to edit text in that default contact
form, you will need to update front-end files Luckily, there is
an alternative
If you are a developer, editing your contact form HTML is an
easy task You only need to open file:
app/design/frontend/default/[yourtheme]/template/
contacts/form.phtml and you will find your way around
However, there are cases when you would like to give your
client an option to edit some intro text, edit his phone
numbers, edit text behind the form, etc You are probably
guessing that it would be nice to be able to embed contact form
in some CMS page No problem
I know that this is not some breakthrough article, but I willcertanly create contact CMS page on all of my future Magentoprojects
Custom price filter in Magento
Quite a few people have asked me for a price filter functionalitythat comes with Magento Mostly, the questions are same:How does one put the price filter anywhere on the page? Howdoes one set it’s on price ranges in that filter? What definesdefault price ranges Is it possible to set price filter for all myproducts instead of just single category? Lot of questions Theanswer might be simpler then you might think
There are two ways to approach this problem Head troughwall or stop and think approach.Default Magento price filterworks with algoritam which functions on the following logic
1 Find the lowest and highest price in the range of filteredproducts
2 Find what power of 10 these are in
3 If there’s 2 or less ranges available we go one powerdown
So one approach would to be to somehow override defaultprice filter logic by rewriting it and embedding some new logic
of yours I call this one head trough wall I’m not implyingthat this is wrong approach, on the contrary this is the genericsolution However it does require some more time to come upwith
Second solution is by far more easier It involves using simpleHTML (could use it in your static blocks)
If one wishes to use the price range filter to filter trough entireproduct collection he can simply create a subcategory underthe Default root category and add all of the products to it Then
we write some static html code with urls made to fire up theprice filter
Let’s look at the default Magento sample data It gies you thefollowing category layout
Root Catalog (6)
• Furniture (6)
• Living Room (4)
Trang 21September 8th, 2009 Published by: inchoo
• Bed Room (4)
Notice the url link above… It wont work if you put it like http://
somesite.domain/furniture/living-room/?price=1%2C199
It wont work like that because by default you do not have price
filter functionality covering second subcategory level What
this means is that following link wont work
http://somesite.domain/furniture/living-room/?
price=1%2C199
Since the first subcategory level is Furniture, and second are
Living Room and Bed Room, by default the following url will
work with or withoutindex.php
And put it into some of the static block Notice the links in
above HTML code The /all part of the url is the url key of the
All category in which we added all of our products
Last, but not least is understanding of the “price=…”
So if we were to write something like
3%2C10 it would be the price range from 20-30, where 3
stands for third range of tens (number 10) Firs is from 0-10,
second 10-20, third 20-30
Most of this is quite selfexplanaory so, for those who needthis kind of functionality across some special pages, hope youintegrate it withouth any problems
There are 4 comments Magentique - Magento Showcase Launched | Inchoo
We launched one internal project today: magentique.com Forthe last few months we were working almost exlusively onMagento projects As many of you, we were also wonderingwhat sites are developed with it There are very little galleriesthat give the list of Magento powered stores and that’s howthis idea was created We present you Magentique and hopeyou like it
Curiosity about this project is that we used Magento to develop
it You’ll not see a shopping cart or Add to Cart buttons, butMagento was the tool we used Take a look at the gallery,comment the sites you like Subscribe to RSS Share it withyou friends Also, we would welcome your submissions of newstores you own, you created or just the ones you like
Hi,
I like your work with Magento, and i see that y’re notaffraid of experimenting My question is relative to http://www.raspberrykids.com I like the layout, especially folder tabwith ‘Description’, ‘Tags’ etc I didnt find such a feature inMagento Can you explain it on Inchoo web (in some article),
of course, only when it isnt company secret ) Thankx Have
a nice day
Online stores on magentique.com are not only our works.Magentique is the gallery that lists all Magento sites and notonly our portfolio
Regarding blog topics, we try to write about the things we work
on However, we can not cover all Magento possibilities Hopeyou agree
Trang 22September 8th, 2009 Published by: inchoo
Created using zinepal.com Go online to create your own zines or read what others have already published. 22
Can an online store have only one product? Sure it can and
we give you the one that just launched Kapitol Reef was
founded to develop, perfect, manufacture and market a new
breed of snorkels based upon pressure-balanced breathing in
the aquatic environment The entire focus for this company
is to deliver best-of-class products, starting with the snorkel
Kapitol Reef is in the market for many years and this week
they published a new site Similar to our work on Teraflex
project, we used Wordpress and Magento platforms for the
development
The request was to have an extensive online store solution
with multiple customers groups Those groups should have
different product prices and different payment options
Magento seemed like a great solution for such a request,
although the initial concern was if it might be an overkill
considering the fact we only have one product to start with?
When the development started to roll out, the concern was no
more This will work superbly We give you the new Magento
store that uses a combination of Wordpress and Magento
Magento portion of the site is visible from the Online Store tab
You may also notice a styled color switcher feature we
developed for this project As this product comes in various
colors, we decided to spice up the product info page and style
the color choosing to replace the default select box
There are 7 comments
Form Validation in Magento | Inchoo
One of the coolest things in Magento is a form validation, and
the way how it’s done Magento uses Prototype library (which,
personlay, I’m not a big fan of) to manage form validation All
you need to do when writing custom form is to assign a valid
class names to your input fields Here is an example of how
your custom form might look in order to get use of automatic
form validation
<form name="<em><strong>my-custom-form</strong>" id="my-custom-form" action="" method="post">
<label for="firstname">< ?php echo $this-> ('First name') ?> <span class="required">*</span></label><br />
<input id="firstname" name="firstname" class="<em/><strong>input-text required-entry</strong>" />
<label for="lastname">< ?php echo $this-> ('Last name') ?> <span class="required">*</span></label><br />
<input id="lastname" name="lastname" class="<em/><strong>input-text required-entry</strong>" />
<label for="useremail">< ?php echo $this-> ('Email') ?> <span class="required">*</span></label><br />
<input type="text" name="useremail" id="useremail" class="<em/><strong>input-text required-entry validate-email</strong>" />
<input type="submit" name="submit" value="<?php echo $this-/> ('Submit') ?>" />
</form>< ?php /* END OF my-custom-form */?>
You will notice all of the input fields have one common
class name, required-entry I’m not gonna go over all of the
available class names here To find available class names, trygoing to One page checkout page, where you have checkoutform, then simply view source and look for class names next
to input, radio select and other fields
Most important thing besides assigning class names is thatlittle piece of JavaScript below the form Remember to pass
form id into the new VarienForm object.
Basically thats it Constructing the form this way, automaticalymakes your form reuse already existing validation code, theone that the rest of the shop is using
There are 5 comments CSRF Attack Prevention
If you login to your Magento admin today, you are welcomedwith message box that says:
CSRF Attack Prevention Read details !Yesterday Magento team acknowledged CSRF vulnerabilityand provided solution in a form of tutorial to change admin
path (frontName) of your Magento shop.
I find this approach strange and funny at the same time Ishiding vulnerability new way of fixing it? Especially sincesome users of French Magento forums found similar problem
in downloader (Magento connect manager) I can confirm thiscouse i tested it myself The most funny part was that Magentocached my get request so i couldn’t get rid of my test alert box
Few fast tips for Magento admins:
1 Follow official Magento news, forums, updates
2 Don’t click suspicious links These kind of attacks areusually done through malformed links that admin clicksthrough mail, comment, or any other source
3 Clear “saved passwords” from browsers Since mostweb browsers offer to remember passwords, and thenautocomplete them, these kind of attack could easily stole yourpassword