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…
Getting the manufacturer of a product (Magento 1)
Use the below code to load the manufacturer of a product:
1 |
$manufacturer = $product->getAttributeText('manufacturer'); |
Loading all crosssell products of a product (Magento 1)
This is how you can load all crosssell products of a product:
1 2 3 4 |
$crossSellProducts = $product->getCrossSellProductCollection() ->addAttributeToSelect(Mage::getSingleton('catalog/config') ->getProductAttributes()) ->setPositionOrder()->addStoreFilter(); |
Getting the type of a product (Magento 1)
Use the following code to get the type of a Magento product:
1 2 |
// configurable, simple, ... $type = $product->getTypeId(); |
Magento 2 error: Could not determine temp directory, please specify a cache_dir manually
If you get the Could not determine temp directory, please specify a cache_dir manually error in Magento 2, the shop is not able to access your PHP temporary folder. To solve this problem, simply add sys_temp_dir to your php.ini file…
Category page loading extremely slow (Magento 1)
If the category page of your Magento store is loading really slow, the configurable swatches might be the problem. Override /app/code/core/Mage/ConfigurableSwatches/Helper/Mediafallback.php and move
1 2 3 4 |
// normalize to all lower case before we start using them $optionLabels = array_map(function ($value) { return array_map('Mage_ConfigurableSwatches_Helper_Data::normalizeKey', $value); }, $optionLabels); |
up to before the foreach loop. This will help increasing the speed of your category page…
Sort order items by SKU (Magento 1)
If you want to change the default sorting of the ordered items on the order detail page, go ahead and override app/design/adminhtml/default/default/template/sales/order/view/items.phtml in your theme and replace
1 2 3 4 5 6 7 8 |
<?php $_items = $this->getItemsCollection() ?> <?php $i=0;foreach ($_items as $_item):?> <?php if ($_item->getParentItem()) continue; else $i++;?> <tbody class="<?php echo $i%2?'even':'odd' ?>"> <?php echo $this->getItemHtml($_item) ?> <?php echo $this->getItemExtraInfoHtml($_item) ?> </tbody> <?php endforeach; ?> |
with
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php $_items = $this->getItemsCollection() ?> <?php $_sortedItems = array(); ?> <?php foreach ($_items as $_item) : ?> <?php $_sortedItems[$_item->getSku()] = $_item;?> <?php endforeach;?> <?php ksort($_sortedItems); // This is where the sorting by SKU takes place ?> <?php $i=0;foreach ($_sortedItems as $_item):?> <?php if ($_item->getParentItem()) continue; else $i++;?> <tbody class="<?php echo $i%2?'even':'odd' ?>"> <?php echo $this->getItemHtml($_item) ?> <?php echo $this->getItemExtraInfoHtml($_item) ?> </tbody> <?php endforeach; ?> |
Done. If you open the detail page of an order…
“Reset password” page empty after installing SUPEE-6788 (Magento 1)
If the password reset page is emtpy after you installed the Magento security patch SUPEE-6788, the problem is most likely to be found in the customer.xml file. Open the customer.xml file of your theme and replace customer_account_resetpassword with customer_account_changeforgotten. The…
Deleting all products using SQL (Magento 1)
To delete all product related data, use the following query:
1 |
DELETE FROM catalog_product_entity; |
Due to the constraints it will delete all related data from other tables as well.
Solving “Invalid login credentials” Magento Connect Manager error
If you get the Invalid login credentials error when using the Magento Connect Manager, you most likely changed your FTP credentials some time ago and the Connect Manager still uses the old credentials. To get rid of this error, simply…