i have a website in magento which contain url like mydomain/Parent-category/sub-category but i wnat to this URL for sub-category Like mydomain/Subcategory.. how can i remove main-category from the URL of sub-category in magento. i want URL like [URL]
If code written for Magento is executed outside of Magento—as occurs when running unit tests—Magento’s normal startup process (which registers its autoload functionality) is not run. Without the autoloader in place, the first time PHP encounters a request to initialize a class which it doesn’t recognize, it will error out with a “class not found” error. Also, without Magento’s startup process running, PHP doesn’t know about the Mage family of singleton methods (e.g. Mage::getModel(), Mage::helper()) which are commonly used to create class instances.
Include/require (perhaps using require_once) app/Mage.php in the code you execute from outside of Magento. When Mage.php is included, the code in that file will register Magento’s autoloader with PHP. Also, Mage.php contains the method definitions for the Mage singleton methods.
Magento handles its get and set methods in a way that if you do not understand how it works it can be confusing to you. In the beginning of this article you have to take a leap of faith and believe in magic.
In Magento you can take nearly any model and get all the information about it with a simple function call. See the example below:
$product = Mage::getModel('catalog/product')->load(1500); print_r($product->debug());
This code will return an array of all the basic information about the product. For this example lets say that it only returned two elements to the array “name” and “meta_description”.
Now in order to get this information you will have to take the information and camel case it to create the function. So to get the information you would write the following:
echo $product->getName(); echo $product->getMetaDescription();
Do you see how the Meta Description function was formatted? The first letter of the words are capitalized (or camelized) to create the function. So lets say you had an attribute called this_really_important_long_attribute you would call $product->getThisReallyImportantLongAttribute()
Now that you understand that, in order to set the attributes value, you simply replace “get” with “set” and pass the variable as a parameter of the function. So to set the name you would make the following function call:
Ok remember when I said that you had to believe in magic? That is because if you look at the Product model, you will not find these functions defined anywhere. In fact if you are hardcore you can follow the class all the way to the top and you will not find these functions defined.
Ok now that you believe in magic, let’s take the curtain away and show you how Magneto accomplishes this. Nearly every class in Magento extends from the Varien Object (which is located in the /lib/Varien/Object.php file). You will see there is a getData() and setData() functions. These look like they could do the actual setting and getting but this is not the magic we are looking for.
Farther down in the file you are going to find the __call() function. This is the magic. This magic here is actually from PHP. The __call() function gets called anytime you call a function on a class that does not exist. The __call() function takes two parameters. The first one is the name of function that was called, the second one is the data that was passed to the function.
IS VARNISH RIGHT FOR YOU?
Varnish isn’t the be-all and end-all of Magento performance. Its great to offset load from bots & window-shoppers – but it shouldn’t be your first port of call to actually making your store faster.
In fact, implementing Varnish should be the last performance modification to your store. Only drop it in once you are seeing the page load times Magento is capable of delivering without it (Eg. <600ms page load times).
YOUR STORE STILL NEEDS TO BE FAST
As Varnish still requires at least a single page load to prime the cache, it means your un-cached performance still needs to be very good. A vast majority of unique URLs (layered navigation hits, search queries etc.) will never really end up being served from Varnish unless either:
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).
Here is a code to retrieve the product review info:
Just be sure to pass it the right product id number.