Category Archives: Magento® Tips

Easy steps – install Magento® 2 Beta version

Magento® 2 is due for the end of year 2015, but you may already want to try it. This new version contains many improvements and is going to be a major upgrade.

While working with Magento® 2, we can easily see that the database structure has been kept, which means that it should be easy to upgrade from Magento® 1 to Magento® 2, but the code has been completely revisited and none of the modules available for Magento® 1 will work on Magento® 2. This is for the good, because now Magento® 2 benefit from:

  • new optimized file structure
  • new layout elements
  • jQuery replaces Prototype JS
  • no more factory names (such as Mage::getModel, Mage::helper, etc.)
  • etc.

We now know that Magento® 2 will contains many improvements, but we need to be prepared to migrate when the d-day will come and here is the steps you can follow in order to install the new version of Magento® on your server:

  • Go to your www root directory and type the following: git clone https://github.com/magento/magento2.git
  • Go to your magneto directory: cd magento2
  • Download composer with the following command: wget -O ./ http://getcomposer.org/composer.phar (alternatively, you can use curl -O http://getcomposer.org/composer.phar)
  • Add sample data to composer.json by using the following command line:
    • php composer.phar config repositories.magento composer http://packages.magento.com
    • php composer.phar require magento/sample-data:">=0.42.0.beta1" magento/sample-data-media:">=0.42.0-beta1" --dev
  • Install Magento® 2 and load sample data: php composer.phar install
  • When installation is done, you can access to your Magento® setup by using the following url: http://127.0.0.1/magento2

Note that you can alternatively install composer as the following:
wget -O /usr/local/bin/composer http://getcomposer.org/composer.phar
chmod +x /usr/local/bin/composer
wget -O /usr/local/bin/composer http://getcomposer.org/composer.pharchmod +x /usr/local/bin/composer

If you do that, you can use commands such as: composer install instead of php composer.phar

Also note that you might need to specify full path of php binary. For example, if you are using XAMPP under mac, you’ll need to do the following: /Applications/XAMPP/bin/php composer.phar… instead of php composer.phar…

Tips of the day while using J2T Reward Social Add-on;)

If you wonder how to modify Facebook image and text while your customer click on like button with the module J2T Reward Social, you may want to modify the file path-to-your-theme/template/page/html/head.phtml in order to add the following:

<meta property=”og:url” content=”<?php echo htmlspecialchars(Mage::helper(‘core/url’)->getCurrentUrl())?>” />
<meta property=”og:title” content=”<?php echo htmlspecialchars($this->getTitle());?>” />
<meta property=”og:description” content=”<?php echo htmlspecialchars($this->getDescription()) ?>” />

<?php if (Mage::registry(‘current_product’)) : ?>
<meta property=”og:image” content=”<?php echo Mage::helper(‘catalog/image’)->init(Mage::registry(‘current_product’), ‘small_image’)->resize(100,100);?>” />
<?php else:?>
<meta property=”og:image” content=”DEFAULT_URL_IMAGE_OF_YOUR_CHOICE” />
<?php endif;?>

No wonder on which page your customers are, they will always have correct title, text and image while clicking on like button!

Possible issues when installing J2t Reward Points

When installing Reward points loyalty system extension, sometimes you can face some issues. The main issue that you can have are:

  1. user account redirection from secure to non secure url (from 1.4.2, you are not having this issue anymore)
  2. problem when creating table, when installing the module
  3. conflict with other modules (not likely)

All these problems can be solved quite easily. Here are how to fix those issues:

  1. to fix secure url redirection in user account, please add in app/code/community/Rewardpoints/etc/config.xml (between frontend tags), the following entry: <secure_url><rewardpoints_index>rewardpoints/index</rewardpoints_index></secure_url>
  2. if you have problem to create tables of the modules, you need to make sure that your mysql user has permission to access COLUMS mysql tables. If you have sql issues, please contact us and we will provide full direction to you
  3. conlicts could arise if you are using other modules dealing with coupon codes and promotion system. Those issues can be fixed quite easily, but you need to be able to find the classes that are overloaded in both modules,  deactivate the overload process from the other module and extands Rewardpoints concerned class to the other module class. Fortunately, you don’t usually have this issue, but if it’s the case, please note that you can request help from us by taking the technical support option. This will allow our team to check the module against your server and we will provide to you a customized version that you will simply need to upload to your server.

We hope that this will help you all!

Load product by SKU

To load a product by SKU, you have two options:

  1. load by attribute
  2. get the product id and load the product according to its id

1st method: load by attribute

$product = Mage::getModel(‘catalog/product’)->loadByAttribute(‘sku’,’PRODUCT_SKU’);

2nd method: get product id and load by product id

$product = Mage::getModel(‘catalog/product’);
$productId = $product->getIdBySku(‘PRODUCT_SKU’);
if ($productId) {
$product->load($productId);
}

$product = Mage::getModel(‘catalog/product’);
$productId = $product->getIdBySku(‘PRODUCT_SKU’);if ($productId) {    $product->load($productId);}

How to use Mage::getBaseUrl

You always wanted to know how to access to your current magento URL.

Here are some example of  Mage:getBaseUrl use:

<?php
Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
Mage::getBaseUrl('skin');
//returned value: http://www.mymagento.com/skin/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
Mage::getBaseUrl('media');
//returned value: http://www.mymagento.com/media/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
Mage::getBaseUrl('js');
//returned value: http://www.mymagento.com/js/

Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
Mage::getBaseUrl('web');
//returned value: http://www.mymagento.com/
?>

You can use a second parameter (true or false) to specify if you want a secure url or not.