July 14th, 2010
Difficulty: Easy
Q:
I want to mark orders as shipped after we import the shipping feed from our warehouse. Is there an API for this? Or do I have to use the actual classes?
A:
Yes, of course! You can use the shipment API, to which you can connect using both SOAP and XML-RPC. The call that will be of most interest to you is shipment.create.
Here’s the sample code from magento’s site [php]:
$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$notShipedOrderId = '100000003';
// Create new shipment
$newShipmentId = $proxy->call($sessionId, 'sales_order_shipment.create', array($notShipedOrderId, array(), 'Shipment Created', true, true));
And here are the comments:
sales_order_shipment.create
Create new shipment for order
Return: string – shipment increment id
Arguments:
string orderIncrementId – order increment id
array itemsQty – items qty to ship as associative array (order_item_id ⇒ qty)
string comment – shipment comment (optional)
boolean email – send e-mail flag (optional)
boolean includeComment – include comment in e-mail flag (optional)
Tags: API, Development, Ecommerce, Magento, Q&A
Posted in Development, Ecommerce, Magento, Q&A | No Comments »
May 14th, 2010
Difficulty: Medium
Modification: Linux crontab
Q:
I have my scheduled tasks set up in magento and cron.php is executed periodically, however, some of the scheduled tasks are not performed. Is there anything I can do about that?
A:
We had the same problem with one of our sites. All the tasks were performed apart from sending the scheduled emails. After many discussions and when we have run out of all reasonable ideas we started looking at some more out of line ones. We noticed that the emails are sent when we access cron.php with a browser. It turns out that sometimes it is not enough to just execute your cron.php with a command line php interpretter in your linux crontab. We had to simulate a standard browser access to this php script by using wget. Here’s a sample line that you need to put in your crontab to make it work:
*/5 * * * * wget -q -O /dev/null http://.../cron.php
This line uses wget to request the cron.php file from the server and then discards the output. After putting this in place the emails were sent and they have been sending nicely ever since.
Tags: Development, Ecommerce, Magento, Q&A
Posted in Development, Ecommerce, Magento, Q&A | 3 Comments »
April 29th, 2010
Difficulty: Easy
Q:
I can’t figure out how to export my product database. Is this possible? I figured out how to export my products, but now I can’t seem to find the file. Where do I go to find the file?
A:
When you use the magento export import features all the files are saved to and read from the server’s filesystem. The files you want to import into the system need to copied (for example via (s)ftp) to /var/import/ directory inside your magento root directory. The files that you export from magento will be placed inside /var/export/.
Tags: Ecommerce, Magento, Q&A
Posted in Ecommerce, Magento, Q&A | 7 Comments »
April 1st, 2010
Difficulty: Medium
Modification: Core Controller
Q:
I am trying to find a way to redirect the url for a simple product to go to the corresponding configurable product. For example if I have a link to a small blue t-shirt, it would go to the main t-shirt page where the attributes are available to select.
A:
You will need to modify the ProductController to make it look for a configurable product and display it when someone asks for a simple product.
The file you need to modify is /app/code/core/Mage/Catalog/controllers/ProductController and the method name is _initProduct().
Find the code which retrieves the product to be displayed:
$product = Mage::getModel(‘catalog/product’)
->setStoreId(Mage::app()->getStore()->getId())
->load($productId);
And add this code after it:
if($product->type_id==“simple”)
{
$parentId=$product->loadParentProductIds()->getData('parent_product_ids');
if(isset($parentId[0]))
{
$product=Mage::getModel('catalog/product')->load($parentId[0]);
}
}
That’s it, simple and elegant.
Tags: Development, Ecommerce, Magento, Q&A
Posted in Development, Ecommerce, Magento, Q&A | No Comments »
March 12th, 2010
Difficulty: Easy
Modification: Store Configuration
Q:
I keep getting complaints from potential customers that they are unable to use magento’s checkout. Instead of going to checkout they are logged out of the system and their cart is emptied. Why is this happening? What can I do about that?
A:
The issue in this case is that magento validates user sessions using their IP addresses. Validating customer’s IP address fails miserably when the customer’s ISP uses a proxy for http connections (and it seems many ISPs do that, at least in the UK). The problem occurs when switching from http to https. When on http, the customer connects through a proxy, so the session is created with the proxy’s IP address. When the customer is redirected to https (eg. goes to checkout) the connection is direct and the proxy is bypassed. Now the customer is connecting from his own IP address and not through a proxy, so his IP has changed. Magento detects this and invalidates the session.
The fix is fairly simple. You have to change the Session Validation settings in the Magento Admin. To do that go to System > Configurations > Web and choose ‘no’ on every option. After doing this, go to System > Cache Management and refresh the configuration cache to apply the changes.
Tags: Ecommerce, Magento, Q&A
Posted in Ecommerce, Magento, Q&A | No Comments »
March 12th, 2010
Difficulty: Easy
Modification: Template File
Q:
I am a newbie at Magento and i need help. Can anyone guide me how to display the search form at the header?
A:
Put this code:
<?php echo $this->getChildHtml(‘topSearch’) ?>
Inside /app/design/frontend/default/your_skin/template/page/html/header.phtml. Then style it so that it appears exactly where you want it. It’s as simple as that!
Tags: Design, Ecommerce, Magento, Q&A
Posted in Design, Ecommerce, Magento, Q&A | No Comments »
March 1st, 2010
Difficulty: Easy
Modification: Config files, Database
Q:
Ok so I went to SYSTEM | ADVANCE and changed the path to log into the admin panel to another name.
Now, I can’t log in to the admin panel.
A:
First of all you would need to undo what you did – unset the custom admin url in the database. To do this, you would need to interact with the database. My preference is to use phpmyadmin, but you might also do it with the command line interface. Go to the table ‘core_config_data’ and delete the rows:
- admin/url/use_custom
- admin/url/custom
After that you need to properly set your custom admin url in the config file /app/etc/local.xml. In this file change this:
<frontName><![CDATA[admin]]></frontName>
to this:
<frontName><![CDATA[your_custom_admin_url]]></frontName>
Now save the file and clear the cache (if you are using it). If you still don’t have access to the admin you may clear the cache by deleting the contentss of the /var/cache directory.
On thing to remember is that while hiding your admin url makes your site more secure, it is not the ultimate solution for all your security issues. If your magento version is lower than 1.4, your admin url is easily discoverable by anyone unless you do some additional tweaking.
Tags: Ecommerce, Magento, Q&A
Posted in Ecommerce, Magento, Q&A | 2 Comments »
February 26th, 2010
Difficulty: Easy
Modification: Template File
Q:
I’m new to magento, and I would like to know if there is a way to hide the price of a product when it is 0?
I have a few free virtual product, and they have 0 as price. so the customer can order them for free. But I would like to hide the 0.
A:
That is fairly easy to do. You will need to modify the template file /app/design/forntend/default/your_skin/template/catalog/product/view.phtml.
In there you need to look for the piece of code responsible for displaying the price and surround it with additional code:
<?php if($_product->price==0): ?>
<?php echo 'FREE'; ?>
<?php else: ?>
<!-- code that is currently displaying the price in your template -->
<?php endif; ?>
Tags: Design, Development, Ecommerce, Magento, Q&A
Posted in Design, Ecommerce, Magento, Q&A | No Comments »
February 18th, 2010
You might have heard that there is a new version of magento out there. Magento Community Edition 1.4 has just been declared stable by its Varien. If you want to upgrade you must bear in mind that by doing so you will overwrite all the modifications in your core files. Normally this should not be a problem, as there shouldn’t be any core modifications. However, it is not uncommon that magento developers and designers do some quick changes in the core and then forget to move them to the local code pool or local template. The only way to make sure that your site will not loose the extra functionality or some custom styling is to track all the changes that have been applied to your core files and either move them to the local code/design files before upgrading or reapply them after the upgrade (though we would really recommend that you keep your core files free from any modifications). Now to the most important part: How to do this?
In order to find the core changes you would need to download a clean copy of magento. Be sure to download exactly the same version that you are currently running (you can check your current version in the admin panel’s footer). After download you need to extract the ‘app’ folder and place it somewhere in your filesystem. For the purpose of this example, lets assume that you put the original app file in the magento root folder and rename it to app.org.
Now you will need to make use of the linux console. The tool you will use is diff. It is a standard program for comparing files that should be present in all linux distributions. The only parameter that would need to be added is -r which switches the tool to recursive mode. The final command looks as follows for:
diff -r magento_root/app/code/core magento_root/app.org/code/core > ~/core_code_modifications.txt
diff -r magento_root/app/design/frontend/default/default/ magento_root/app.org/design/frontend/default/default/ > ~/core_design_modifications.txt
After executing those two commands you will have two files created in your home directory:
- core_code_modifications.txt, which will list all the modifications in your core code files
- core_design_modifications.txt, which will list all the modifications in your default template
With that knowledge your job of upgrading magento will be much simpler. Again, after you have successfully upgraded your magento store to version 1.4, do take some extra time and move the changes to the local code pool and/or your custom template. This will save you a lot of time and trouble in future upgrades and will also ensure that your store is easier to maintain by your developers and designers.
Tags: Design, Development, Ecommerce, Magento
Posted in Design, Development, Ecommerce, Magento | 4 Comments »
February 15th, 2010
I know we shouldn’t get too obsessed with page rank but I always like to keep a look out for websites that get a perfect 10 page rank, this changes each quarter and we should be due for an update very soon, below is a list of all the sites that have a pr 10.
|
Title
|
PR
|
GBLs ( Google’s Fake representation refer webmaster tools for )
|
YBLs
|
URL
|
|
Google Search
|
10
|
132,000
|
1,041,958,589
|
http://www.google.com
|
|
World Wide Web Consortium
|
10
|
33,000
|
66,868,007
|
http://www.w3.org/
|
|
US Goverment website
|
10
|
29,800
|
5,507,662
|
http://www.usa.gov/
|
|
Adobe – Adobe Reader Download
|
10
|
366,000 |
1,426,347
|
http://get.adobe.com/reader/
|
|
National Portal of India
|
10
|
2,270
|
250,770
|
http://india.gov.in/
|
|
United States Department of Health and Human Services
|
10
|
34,400
|
2,528,270
|
http://www.hhs.gov/ and http://www.dhhs.gov both redirects to same URL.
|
|
Europeana
|
10
|
5,030
|
458,308
|
http://www.europeana.eu/portal/
|
|
CNN
|
10
|
46,100
|
23,149,725
|
http://www.cnn.com/
|
|
Miibeian
|
10
|
31,200
|
824,087,644
|
http://www.miibeian.gov.cn/
|
|
Social Bookmarking Sharing Button Widget
|
10
|
151,000
|
340,345,651
|
http://www.addthis.com/bookmark.php
|
|
ScienceDirect
|
10
|
8,200
|
1,539,714
|
http://www.sciencedirect.com/
|
I will post the result of the next update. It will be interesting with the ever-changing parameters that Google puts in our way to see if this list increases or shrinks.
Posted in Uncategorized | No Comments »