Category Archive for "Magento"

Load product in magento by SKU or product id

To load product using product id we can use below code. $product = Mage::getModel(‘catalog/product’)->load($product_id); We can also load product using SKU. Below is the code for load product using SKU. $_sku = ‘product_sku’; $_product = Mage::getModel(‘catalog/product’)->loadByAttribute(‘sku’,$_sku); echo $_product->getName();

Read More

Warning: simplexml_load_string() in Magento

Warning: simplexml_load_string() in Magento This error comes when there is any unwanted white space in any file or in the URL path. To fixed this error connect to database and open table core_config_data. find web/unsecure/base_url and web/secure/base_url URL in this…

Read More

Direct SQL Queries In Magento

Let’s assume we need to fetch data from direct database and we don’t want to use model in magento. At that time we can also access data direct from database using magento database connection and simple SQL query. Below is…

Read More

Get product image in Magento

Magento basically have 3 different types of product image which are as followed. Base Image Small Image Thumbnail image Now let’s see how we can get product images using product id. $products = Mage::getModel(‘catalog/product’)->load(900); echo $products->getImage(); echo $products->getSmallImage(); echo $products->getThumbnail();…

Read More

Get product collection filter by category id in magento

Below is the code by using we can get product collection filter by category id in magento $category = Mage::getModel(‘catalog/category’)->load(‘category_id’); $productCollection = $category->getProductCollection(); $productCollection ->addStoreFilter() ->setVisibility(Mage::getSingleton(‘catalog/product_visibility’)->getVisibleInCatalogIds()) ->addMinimalPrice() ->addFinalPrice() ->addTaxPercents() ->addAttributeToSelect(Mage::getSingleton(‘catalog/config’)->getProductAttributes()) ->addUrlRewrite();

Read More

Filter product collection with multiple SKU magento

Suppose, you need product information of more then one product using SKU at that time we can get all information using “array in” with filter. Below is code for the same. you just need to change SKU name in below…

Read More

Class Magento\Authorization\Model\Acl\Role\GroupFactory does not exist magento2

Getting error Class Magento\Authorization\Model\Acl\Role\GroupFactory does not exist magento 2 is quite complex to understand. We frequently get this error while developing store. Here is solution to fix this error. 1) go to var folder and find generation. now remove folder….

Read More

Update database password in magento

Changing database password frequently is always good practice to make your store secure and it will protract your store with malware and other hacking attacks. Below are the steps how to change database password in magento. 1) Connect to your…

Read More

How to change admin url in magento

By default we can access magento admin by simple using /admin after magento store URL. To secure your store its preferable that you change default URL of Magento store. Below are the steps to change admin url in magento. 1)…

Read More

Magento get login customer information

Suppose we want to get all information of login User like Full Name, First Name, Middle Name, Last Name etc. We can also check user registration date, Date of Birth and many more information. Below is code to display information…

Read More