GRANT ALL ON magento2 TO magentouser localhost IDENTIFIED BY 123456 WITH GRANT option

Search the Wiki

Sort by: Show:

Viewing 136 to 180 of 229 items

Magento – Delete Empty Null Attribute Options

By default, if you enter attribute options in the back end, you can’t add an empty option to the attribute. Maybe these empty options were added via a custom script. Here is the custom script that helps you to remove the empty options of the attributes 1.Create store_root/shell/empty.php file with code snippet: 2.Run this PHP script to  Full Article…

Magento – DIRECT SQL QUERIES IN MAGENTO

Magento’s use of data models provide a great way to access and modify data. Using aptly named methods and clever abstraction, Varien hide away the complex SQL needed to perform data operations. While this makes learning models easier, it often impacts the speed of the operation and therefore the responsiveness of your site. This is  Full Article…

Magento – DISPLAY CATEGORIES AND SUBCATEGORIES IN MAGENTO

Listing Categories in Magento 1.4.1.1 & Above Firstly, you need to make sure the block that you’re working is of the type catalog/navigation. If you’re editing catalog/navigation/left.phtml then you should be okay. In my previous example, we used the Category model to load in category information. This can be slow and often loads in more  Full Article…

Magento – Filter product collection by special price

To create a new page with products have special price only, you need to create a new block that filters discounted products.  Let’s create this file, Special.php in local/Mage/Catalog/Product/Block/ directory. You will have to create this directory path if it’s not already there. Using below code to create new block  <?php class Mage_Catalog_Block_Product_Special extends Mage_Catalog_Block_Product_List  Full Article…

Magento – Filtering results using LIKE

When you want to filter collection result by using like, you can use the following code: $collection->addAttributeToFilter('name', array( array('like' => '% '.$needle.' %'), //spaces on each side array('like' => '% '.$needle), //space before and ends with $needle array('like' => $needle.' %') // starts with needle and space after )); Passing the second parameter as an  Full Article…

Magento – Force secure urls (https) on all frontend pages.

This solution works in Mageno 1.9.1. You need to update the app/etc/config.xml file <?xml version=”1.0″?> <config> <frontend> <secure_url> <all>/</all> </secure_url> </frontend> </config>   If user is using https, this should force all urls to rewrite (created as) to https.

Magento – Functions cheatsheet

General functions Function Description $this->getRequest()->getServer(‘HTTP_REFERER’); Get the referer URL Product related functions Function Description $product->getName() Get product name $product->getSku() Get product sku Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty() Get product stock $product->getResource()->getAttribute(‘color’)->getFrontend()->getValue($product) Get a product attribute value (like color/size) $product->isSaleable() checks if a product is salable $product->isisAvailable() checks if a product type is salable Mage::getModel(‘catalogrule/rule’)->calcProductPriceRule($product,$product->getPrice()) Gets the product final price  Full Article…

Magento – Get comment history of the order

You can use the below code to get the comment history of the order. $orderId = 100000454 ; $order = Mage::getModel(‘sales/order’)->loadByIncrementId($orderId); $commentsObject = $order->getStatusHistoryCollection(true); foreach ($commentsObject as $commentObj) { echo $commentObj->getComment() .” created at”.$commentObj->getCreatedAt() ; }

Magento – Get order detail from order id

Magento get order details : If you are working with magento order and looking for order details you can load order in two ways – Order – Load By Increment Id Order – Load By Entity Id You can use either method to load order in magento. We are going to explain the magento order  Full Article…

Magento – Get the last added product and cart items

This code will show you how to get the product id of the last product that was added to the shopping cart, and all the products currently in the shopping cart. $productID=Mage::getSingleton('checkout/session')->getLastAddedProductId(true); echo $productID."<br>"; $_product=Mage::getModel('catalog/product')->load($productID); echo $_product->getName()."<br>";   $session= Mage::getSingleton('checkout/session'); foreach($session->getQuote()->getAllItems() as $item) {     $productID = $item->getProductId();     $productSku = $item->getSku();     $productName = $item->getName();     $productQty = $item->getQty();  Full Article…

Magento – Get the last order ID

There are many ways to get the last order ID in Magento, here is the detail:  1. From the checkout session.   $lastOrderId = Mage::getSingleton(‘checkout/session’) ->getLastRealOrderId(); $orderId = Mage::getModel(‘sales/order’) ->loadByIncrementId($lastOrderId) ->getEntityId(); This solution will not work in case you want to get the last order ID in the backend. 2. From the model. $orders =  Full Article…

Magento – HOW TO EXCLUDE BLOCK FROM THE FULL PAGE CACHE

Magento Enterprise Edition Full Page Cache is a great feature that significantly improves the frontend performance. Nevertheless, it is causing the troubles with the customisations that require the dynamic content output. As you may know, the customer and cart information custom outputs are the first “victims” there, especially, if you migrated your Magento store from Community  Full Article…

Magento – How to optimize

Magento’s cache system Magento & Zend Framework Before we go on with various optimization points, it is needed for everyone to understand truly and in depth the Magento two level cache mechanisms. The Magento cache system inherit from Zend Framework‘s (ZF) one. Nothing really surprising there, Yoav has always been close to Zeev & Andy and like this Framework  Full Article…

Magento – How to redirect to previous page

Sometimes you will want to redirect to previous page after executing a function.  You can try this: $this->_redirectReferer(); It does a little more than redirect to the previous page. If you specify in the url a parameter uenc it will consider that as the referrer.

Magento – How to set the tax configuration in the correct way

The following general fixes were made to Magento tax configuration and calculations: Canadian customers now receive an e-mail with the correct totals for invoices and credit memos that include Provincial Sales Tax (PST) and Goods and Services Tax (GST). Resolved issues with incorrect prices and incorrect tax amounts when a custom price is used together  Full Article…

Magento – Product Collection

In this blog, we will see some important function in magento product collection class. Product Collection class in magento is Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection. Lets look at the important functions Get All Products of a category 1 2 3 $collection = Mage::getResourceModel('catalog/product_collection')             ->setStoreId($this->getStoreId())             ->addCategoryFilter($category); Tn this the addCategoryFilter() function, is used to get all products of a particular  Full Article…

Magento – Removing all products and log tables

You can use the following commands to remove all products and logs.   SET FOREIGN_KEY_CHECKS = 0; TRUNCATE TABLE `catalog_product_bundle_price_index`; TRUNCATE TABLE `catalog_product_bundle_selection`; TRUNCATE TABLE `catalog_product_bundle_selection_price`; TRUNCATE TABLE `catalog_product_bundle_option_value`; TRUNCATE TABLE `catalog_product_bundle_option`; TRUNCATE TABLE `catalog_product_entity_datetime`; TRUNCATE TABLE `catalog_product_entity_decimal`; TRUNCATE TABLE `catalog_product_entity_gallery`; TRUNCATE TABLE `catalog_product_entity_group_price`; TRUNCATE TABLE `catalog_product_entity_int`; TRUNCATE TABLE `catalog_product_entity`; TRUNCATE TABLE `catalog_product_entity_media_gallery`; TRUNCATE TABLE  Full Article…

Magento – Security tips and vulnerabilities

The term “hacker” was coined in the 1960th by the group of programmers from the Massachusetts Institute of Technology and originally meant a person who looked for a way to smartly make things more functional and useful. But nowadays it usually possess a negative meaning referred to computer criminals. E-commerce and financial sites stand first  Full Article…

Magento – Select all values of an attribute by using SQL

It is useful to be able to export lists of brands, whether you just need a quick list directly from PHPMyAdmin, or you need to pull this information into 3rd party app. To get all the attribute values for an attribute called brands, you can run the following query SELECT EAOV.VALUE FROM eav_attribute EA LEFT  Full Article…

Magento – Set and unset system messages

You can use this code to clear error message  Mage::getSingleton('core/session')->getMessages(true); // The true is for clearing them after loading them You can use the following code show the Magento message //A Success Message Mage::getSingleton('core/session')->addSuccess("Some success message"); //A Error Message Mage::getSingleton('core/session')->addError("Some error message"); //A Info Message (See link below) Mage::getSingleton('core/session')->addNotice("This is just a FYI message…"); //These  Full Article…

Magento – Set custom title of the success page

If you want to change the title of the onepage success page. By default the text is "Magento Commerce", you can change it by following this way. Add this code in checkout.xml under checkout_onepage_success tag <reference name="head"> <action method="setData" translate="title"><key>title</key><value>your title </value></action> </reference>  

Magento – Set default value to custom attribute for all products

I have created the custom attribute (test) for products as a text field with default value('test') from admin panel And assign that attribute to default attribute set. Now I can able to see the new custom attribute in product edit page. When I try to filter with the product collection Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('*') ->addAttributeToFilter('test', array('like' => 'test'))->getData(); It returns the  Full Article…

Magento – Set the default direction or ordering for category-pages

On Magento category-pages you can select how to view the available products: By price, name or relevance, and ascending or descending. Within the Magento backend, the default ordering (price, name or relevance) can be configured but strangely enough the default direction (ascending or descending) not. Here is a XML layout update that allows you to  Full Article…

Magento – The fastest way to update a product attribute

In a beautiful day, my client requires updating the product stock status for around 200,000 products in Magento, the data gets from the XML files. The issue is the XML files will be renewed every day, it means I need to finish updating all products within 24 hours. There is a problem for 200,000 products  Full Article…

Magento – Truncate Magento sales_flat_quote* tables

Recently, we have run into a few stores where the sales quote tables have grown beyond all proportion and resulted in the store grinding to a halt. The worst that we have seen so far is a Magento Enterprise installation that had 17 million entries, consuming a huge amount of space and locking dozens of  Full Article…

Magento – Update admin routers of custom module for patch

I managed to change my custom module to use the Magento new way as recommended with the patch 6788. So I give here as a reference for other. Change to router in the config.xml file: Before: <admin> <routers> <adminhello> <use>admin</use> <args> <module>Pulsestorm_Adminhello</module> <frontName>admin_adminhello</frontName> </args> </adminhello> </routers> </admin> After <admin> <routers> <adminhtml> <args> <modules> <adminhello before="Mage_Adminhtml">Pulsestorm_Adminhello_Adminhtml</adminhello>  Full Article…

Magento – URL Rewriting Tutorial

How to manage URL rewriting in Magento Search engine friendly URLs improve the indexing and ranking of your site, make it easier for people to come across your site when searching through search engines for particular keywords, and generally are easier to remember and improve the navigation on your site. When you add a product  Full Article…

Magento – User manual for Delivery Extension

Delivery Schedule User Guide Admin can easily configure the Delivery Schedule module at Backend => Delivery Schedule => Configuration. Configuration Format Date: Allow admin to choose format date. At Frontend, each time slot will be displayed as the selected format. Weeks: Maximum number of weeks that customers can select delivery date. For example: When admin inserts 4 in this field,  Full Article…

Magento – Check if the SKU is exist

<?php $sku = 'Your Product Sku'; $id = Mage::getModel('catalog/product')->getIdBySku($sku); if ($id){     echo "SKU {$sku} exists"; } else{     echo "SKU {$sku} does not exist"; } ?>

Magento – List of Shopping Cart Price Rule Tables

Here is the table list of Shopping Cart Price Rule. 1. salesrule Create rule info will get it from here. 2. salesrule_coupon Coupon info will get here 3. salesrule_coupon_usage How many time used this coupon by customer ID 4. salesrule_customer 5. salesrule_customer_group Rule mapped to which customer groups 6. salesrule_label 7. salesrule_product_attribute attribute based rule  Full Article…

Magento : Get Store Id, website Id, website info

After hours of searching on Google, i find out some ways to get Store and Website info 🙂 Get current store:       Mage::app()->getStore(); Get current store Id: Mage::app()->getStore()->getId(); Get current website Id: $storeId = Mage::app()->getStore()->getId(); Mage::getModel(‘core/store’)->load( $storeId )->getWebsiteId(); Get store info by store code: $storeCode = “your_store_code”;   Mage::getModel( “core/store” )->load( $storeCode ); Get website info  Full Article…

Magento 2 – Get min price or max price from product collection

Today we learn about how to get min price and max price from product collection. First, you have to get a collection of the product. Then their two predefined functions for getting min price getMinPrice and get max price getMaxPrice Now we implement the code for getting min price and max price. protected $_productCollectionFactory; public  Full Article…

Magento 2 – How to fix Exception SessionHandler

The Issue You may face the following exception during the Magento 2 installation: 12345 exception ‘Exception’ with message ‘Warning: SessionHandler::read(): open(..) failed: No such file or directory (2) ../magento2/lib/internal/Magento/Framework/Session/SaveHandler.php on line 74’ in ../magento2/lib/internal/Magento/Framework/App/ErrorHandler.php:67 The error occurs only in older code versions. To be more exact, you won’t see this exception working with versions from September 29,  Full Article…

Magento 2 – Update new version in 3 easy steps

Today I will describe how you can perform a Magento 2 upgrade. When you run an eCommerce store it is vital to stay secure and up to date. You should always look out for the latest M2 version and update promptly. A word of advice: always backup your files and database before attempting an upgrade. With a  Full Article…

Magento 2 – Write logs to the custom files

In Magento 2, you can use the following code to write logs to the custom files $writer = new \Zend\Log\Writer\Stream(BP . ‘/var/log/templog.log’); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->info(“Log info: “. $e->getMessage());

Magento Category Collection Grid/List View

Now let start with explanation and steps. Please go through the previous blog on paging to understand this better.   Step1: IndexController In the indexcontroller of your module we will write very simple code, to just load and render the layout. 1 2 3 4 5 6 7 8 9 <?php class Excellence_Collection_IndexController extends Mage_Core_Controller_Front_Action {     public function  Full Article…

Magento Fatal error: Class ‘Net_IDNA2’ not found in…..

When you deploy Magento to live server, everything is working fine, except when you save the configuration in back-end the issues occur. If it shows this message “Magento Fatal error: Class ‘Net_IDNA2’ not found in…..” you should not worry about it, because it is not your Magento’s issue, it is the server issue. When you  Full Article…

Magento PayPal Post Back Bug

Maybe anyone can help solve this issue. Everything worked fine ages, and yesterday, PayPal post back failed. It stopped updating any statuses. Log is showing [postback_to] => //www.paypal.com/cgi-bin/webscr [postback] => mc_gross=1.00&invoice=100002123&auth_exp=08%3A29%3A30+Oct+19%2C+2014+PDT&protection_eligibility=Ineligible&address_status=unconfirmed&item_number1=test&payer_id=8EUEYETHYRST8&tax=0.17&address_street=%D1%84%D1%8B%D0%B2%D1%84%D1%8B%D0%B2%D1%84%D1%8B%D0%B2&payment_date=08%3A29%3A30+Sep+19%2C+2014+PDT&payment_status=Pending&charset=UTF-8&address_zip=dsfsdf&mc_shipping=0.00&mc_handling=0.00&first_name=Sergey&transaction_entity=auth&address_country_code=LV&address_name=%D1%8B%D0%B2%D1%84%D1%8B%D0%B2+%D0%B2%D1%84%D1%8B%D0%B2&notify_version=3.8&custom=&payer_status=verified&business=Info%40eurofishshop.com&address_country=Latvia&num_cart_items=1&mc_handling1=0.00&address_city=%D1%84%D1%8B%D0%B2%D1%84%D1%8B%D0%B2&verify_sign=ALBe4QrXe2sJhpq1rIN8JxSbK4RZAc6KHII6HCE8Yo15IkQfFCf9w2Yp&payer_email=ianjanho%40gmail.com&mc_shipping1=0.00&parent_txn_id=&txn_id=1WA86899Y17300749&payment_type=instant&remaining_settle=10&auth_id=1WA86899Y17300749&last_name=Yakovel&address_state=J%C4%93kabpils&item_name1=test&receiver_email=Info%40eurofishshop.com&auth_amount=1.00&quantity1=1&receiver_id=BU6HTDF6LYK4L&pending_reason=authorization&txn_type=cart&mc_gross_1=0.83&mc_currency=EUR&residence_country=LV&transaction_subject=&payment_gross=&auth_status=Pending&ipn_track_id=b4311d9ee7e6&cmd=_notify-validate [postback_result] => HTTP/1.1 403 Forbidden Server: AkamaiGHost Mime-Version: 1.0 Content-Type: text/html Content-Length: 285 Expires: Fri, 19 Sep 2014 15:30:16 GMT Date: Fri, 19 Sep  Full Article…

Magento PHP 5.4 PDF invoice Zend error

Magento PHP 5.4 PDF invoice Zend error Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct() in /var/www/vhosts/website/httpdocs/includes/src/Zend_Pdf_FileParserDataSource_File.php on line 41   This an incompatibility issue between PHP Version 5.4.4 and zend Framwork . Fixed it by change in this function lib/Zend/Pdf/FileParserDataSource.php. change abstract public function __construct(); to abstract public function __construct($filePath);

Mail bouncing… receiving email issue

Starting from sometime yesterday (cannot be sure when without digging through logs) mail is now bouncing from my server. I'm sorry to have to inform you that your message could not be delivered to one or more recipients. It's attached below.   For further assistance, please send mail to <postmaster>   If you do so,  Full Article…

Make a link to cover an entire div

If you want a link to cover an entire div, an idea would be to create an empty <a> tag as the first child: <div class=”covered-div”> <a class=”cover-link” href=”/my-link”></a> <!– other content as usual –> </div> div.covered-div { position: relative; } a.cover-link { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } This  Full Article…

Chủ đề