Showing posts with label Magento. Show all posts
Showing posts with label Magento. Show all posts

Sunday, October 2, 2016

Magento 2.0 - Display custom attribute on product listing page

In product list page you can display like this.
$attribute = $_product->getResource()->getAttribute('attribute identifier'); if ($attribute) { $brick_value = $attribute ->getFrontend()->getValue($_product); }

Tuesday, July 14, 2015

Magento product types explained

Magento product types explained

Magento product types explained

Magento has various product types which all have slightly different functions. It's smart to take them all in consideration before choosing the Magento product type for your items. You probably think like: "Old news!", but before you move on… Do you know the difference between a Magento grouped product and a Magento bundle product?

Magento simple products

A Magento simple product is the most used product type for Magento webshops. This is because it's the most general product type of them all. A Magento simple product should be used for a single item without any specific selectable variations. Think about a coffee cup, a chandelier, a table or whatever.

Magento grouped products

A Magento grouped product should be used for a combination of Magento simple products. Think about a coffee cup that is sold together with a saucer, a silver spoon, a breakfast plate or whatever. You can't define a specific price for a Magento grouped product but you can define a discount amount.

Magento configurable products

A Magento configurable product should be used for a single item with specific selectable variations. Think about a coffee cup obtainable in different colours and sizes, a woman's bag obtainable in different materials, a light boll obtainable in different watts or whatever. Each selectable variation can have its own additional costs.

Magento virtual products

A Magento virtual product should be used for a virtual (not touchable) item. Think about an insurance, a reservation, an extra product guarantee or whatever. A virtual product does not allow selecting a shipping method at checkout simply because there's nothing to ship.

Magento bundle products

A Magento bundle product should be used for a bundle of simple (or virtual) products which are not to be sold separately. Think about a laptop where the customer can choose various items such as hard disk, processor, internal memory or whatever. Each of these items are simple (or virtual) products but can only be sold within the bundle product.

Magento downloadable products

A Magento downloadable product should be used for online software items. Think about an MP3 file, a PowerPoint presentation, a Magento extension or whatever. A downloadable product does not allow selecting a shipping method at checkout simply because there's nothing to ship.

Tuesday, February 24, 2015

Configuring Magento for development

New to the Magento or just used to doing things one way? Here are few tips for configuring Magento for development, in case you overlooked them. Please note, the more proper title of this article would be something like: Configuring Magento for development on local machine (after installation config). Meaning the tips outlined here only apply after the Magento is already installed.
Here are the steps that you should do in order to set your Magento more suited for development:
  • System > Cache Management > Disable All
  • System > Configuration > Advanced > Developer > Log Settings > Enabled => Yes
  • System > Configuration > Web > Search Engine Optimization > Use Wbe Server Rewrites => Yes
  • System > Index Management > Reindex All
  • Open .htaccess and set: SetEnv MAGE_IS_DEVELOPER_MODE “true” at the end of the file
  • Open .htaccess and set: php_value display_errors On somewhere within <IfModule mod_php5.c>
  • Rename /errors/local.xml.sample to /errors/local.xml
  • Create one sample customer with full valid American address (for example use US/California, city Alamo with ZIP 94507), and one with full valid non American address (other country) to test payment and shipping gateways properly
  • Compensate for the possible lack of email server by doing something like explained in this article
Hope it helps.

Tuesday, November 20, 2012

Authenticating Customer Outside Magento

<?php
/**
* Magento validation starts here
*/
require_once (dirname(dirname(realpath(__FILE__))).'/app/Mage.php');
umask(0);
Mage::app();
//Mage::getSingleton('core/session', array('name'=>'frontend'));
$session = Mage::getSingleton('customer/session');
try{
$session->login($_REQUEST['login']['username'],$_REQUEST['login']['password']);
$session->setCustomerAsLoggedIn($session->getCustomer());
//Load the customer modules
$customer = Mage::getModel('customer/customer')
->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
//Get customer attribbutes
$customer->loadByEmail($_REQUEST['login']['username']);
/**
* Do the stuff you need to when user authenticates
*/
}catch (Exception $e){
$key ="authenticate=N";
}

Friday, November 9, 2012

How to access Magento user's session from outside Magento?

<?php
require_once dirname(__FILE__).'/app/Mage.php';
umask(0) ;
$_SESSION['wz']['customer_id']    =    null;
Mage::app();

// Checking for customer session
Mage::getSingleton('core/session', array('name'=>'frontend') );
$session=Mage::getSingleton('customer/session', array('name'=>'frontend') );

$customer_data = Mage::getModel('customer/customer');

if ($session->isLoggedIn()) {
    //echo "Customer is logged in";
    $_SESSION['wz']['customer_id'] = $session->getId();
} else {
    //echo "Customer is NOT logged in ";
    unset($_SESSION['wz']);
    header("Location: error.php?mode=unk_user");
}

Unable to login into the Magento backend


When you migrate your Magento website from location to another, or you change the domain-name under which it is running, you might run into the problem that you can't login anymore to the Magento Admin Panel. Here are various solutions to this problem.

Localhost

One reason why the Magento login fails, might be that you're accessing the Magento website through the hostnamelocalhost. Magento checks whether the hostname is a real domainname, and if it isn't, it fails to create the right cookies.
The only workaround is to fool Magento into thinking a real domainname is used. Under Linux or MacOS you could try using localhost.localdomain, but under Windows you will need to modify your hosts-file for this. Easier is just to use the IP-address 127.0.0.1 to access Magento.
If you are using a remote webserver, it's unlikely that this problem occurs.

Cookie domain

Another reason why you fail to login, could be some setting within the Magento configuration. To alter this, you will need to open up the MySQL database - for instance by using phpMyAdmin. Navigate within your Magento database to the MySQL table core_config_data and look for a row with the field path set to the value web/cookie/cookie_domain. There might be multiple entries, but the one with the scope_id set to 0 should be matching the domainname you're using to access Magento.
If the database table core_config_data doesn't contain any row with path set to web/cookie/cookie_domain, don't add it because you don't need it. If you find multiple entries, be careful with what to change because you might break your Magento site completely.
If you use a database table prefix, the table core_config_data might actually be uii44_core_config_data or something alike. This makes it harder for hacker to attack your Magento site (SQL injection attacks).

Secure or unsecure URLs

Another problem could be that the so-called Secure URLs and/or Unsecure URLs do not match the current hostname. In this circumstance, Magento tries to redirect to the original hostname anyway. So watch the hostname in the browsers addressbar closely.
In the same MySQL table core_config_data you might find various entries with path starting with web/secure/base orweb/unsecure/base. These also need to point to the right hostname. Note that the number of occurances could range from 0 (nothing configured) to 10 (everything configured).

Deleting and reconfiguring

Instead of trying to set the values above correctly, which could be a lot of work, you can also delete these entries and have a fresh start. You can use the following SQL-queries for this:
DELETE * FROM `core_config_data` WHERE `path` = "web/cookie/cookie_domain"
DELETE * FROM `core_config_data` WHERE `path` LIKE "web/secure/base%"
DELETE * FROM `core_config_data` WHERE `path` LIKE "web/unsecure/base%"

Check your file permissions

It's also worth taking a look at the permissions of your hosting environment. The folder var/cache within your Magento installation needs to be writable to the webserver, so new session-files can be created. If the folder is not writable, nobody is able to login.

Save sessions in the database

Instead of fixing the file permissions, you can also store the sessions in the database instead. You can accomplish this by editing the file app/etc/local.xml. Make sure you have a good backup of this file, and follow the exact syntax as below.
Locate the line starting with <session_save> and change the word files into db. So the following:
<session_save><![CDATA[files]]></session_save>
should become:
<session_save><![CDATA[db]]></session_save>
Save the file and sessions will be saved in the database instead. Please note that this change could have consequences regarding performance as well.