Would you like to test or style your stores success.phtml without reordering all the time? It can be done using the following temporary change: Open /app/code/core/Mage/Checkout/controllers/OnepageController.php and look for the successAction() function. Now remove the line $session->clear();. Important: Please note…
Testing success.phtml without placing another order (Magento 1)
Want to make changes to success.phtml (Magento’s order success page) without having to place a new order every time? The following temporary modification makes that possible. Open /app/code/core/Mage/Checkout/controllers/OnepageController.php and find the method successAction() and remove the line $session->clear();. Important: This…
Getting child categories with flat categories enabled (Magento 1)
If you enable the flat categories in your Magento store, some code that gets children of a given category might stop working. The following code can be used to get all the cildren of a given category with enabled flat…
Fatal error: Only variables can be passed by reference in search.phtml (Magento 2)
Do you get the Fatal error: Only variables can be passed by reference in vendor/magento/module-backend/view/adminhtml/templates/system/search.phtml error in your Magento 2 store when calling the backend? To fix that issue, simply deactivate asp_tags in your php.ini. After that, the Magento 2…
Loading child categories with flat categories enabled (Magento 1)
If flat categories are enabled in your Magento store, you need to load the child categories of a given category differently. The following code shows how:
|
1 2 3 4 5 |
$category = Mage::getModel('catalog/category')->load($id); $childCategories = $category ->getCollection() ->addAttributeToSelect(array('name', 'image', 'description')) ->addIdFilter($category->getChildren()); |
Fixing Fatal error: Only variables can be passed by reference in search.phtml (Magento 2)
If your Magento 2 store displays the error Fatal error: Only variables can be passed by reference in vendor/magento/module-backend/view/adminhtml/templates/system/search.phtml when you open the admin area, you need to disable asp_tags in php.ini. After that, the admin area should load normally.
Where can I find the database credentials? (Magento 2)
Want to change the MySQL credentials for your Magento 2 store? Unlike Magento 1, Magento 2 no longer stores them in /app/etc/local.xml. You can find all the necessary details in the file /app/etc/env.php.
Changing the default sort order on category pages (Magento 1)
You can adjust the sort order for an individual category under that category’s Display Settings. To change the sort order for all categories, however, it is best to add a layout update directly to local.xml: desc asc desc asc
Getting the value of a category attribute (Magento 1)
Use this code to retrieve the value (rather than the ID) of a category attribute: $value = $currentCategory->getResource()->getAttribute(‘attribute_identifier’)->getFrontend()->getValue($currentCategory);
Getting the manufacturer of a product (Magento 1)
Use the below code to load the manufacturer of a product: $manufacturer = $product->getAttributeText(‘manufacturer’);