Coding

Hook ajax of prototype

Hook ajax of prototype

  Ajax.Responders.register({   onComplete: function(request, transport) {      console.log(request.transport.responseText)      console.log(transport.responseText)      console.log(JSON.stringify(transport)); //if return json   }  })

Read more

Magento : SMTP settings for Magento

Magento : SMTP settings for Magento

If you want to send emails with Magento you need to configure it to use an SMTP server – that is, the outgoing server that takes care of delivering your messages.   Remember anyway that if you set a normal SMTP server on Magento – like the ones associated to Gmail or Hotmail – you could always run...

Read more

Magento : Add custom field image to CMS page

Magento : Add custom field image to CMS page

 To add a custom field to CMS page we will use Magento event mechanism. You can see all events here.  We need to make a module to extend the functionality of CMS page model. We will name it Flexishore_Cms. Add file named Flexishore_Cms.xml to the app/etc/modules directory. Add the folowing content:   <?xml...

Read more

Magento : Show address fields in account creation form

Magento : Show address fields in account creation form

Add config to xml : <customer_account_create>   <reference name="customer_form_register">     <action method="setShowAddressFields">     <param>true</param></action>   </reference> </customer_account_create>

Read more

SASS : Fix error compilation of awesome font

SASS : Fix error compilation of awesome font

/* modified mixin */ @function unicode($str){     @return unquote("\"") + $str + unquote("\""); }   /* icon code stored in sass variable */ $icon: \f00c;   /* using the variable */ .some-class {     content: unicode($icon); }

Read more

Magento: Getting Skin Urls in transactional emails

Magento: Getting Skin Urls in transactional emails

A problem I have come across before is when I want to include an image within a transactional email, using:   {{skin url="path/here/"}}   The problem being that by default, the transactional emails will look in the skin folder for the admin area in the base package. However if your storing images...

Read more

Magento: Switchable Install Script Setup Class

Magento: Switchable Install Script Setup Class

When doing some database upgrades in Magento, and in general, the best and the smartest way would be to create install or upgrade scripts to keep a persistent data structure. When a core setup is not enough and attributes have to be created or updated, either the customer or catalog product setup class has to be defined....

Read more

How to upgrade php in xampp

How to upgrade php in xampp

[ratings]Lots of time you need to use multiple version of php for your different project. In this case either you want to install xampp on different port or you can install one xampp and upgrade php. In this article I will demonstrate how you can upgrade php in your xampp server. I will demonstrate the complete...

Read more

Magento : Validation of form input

Magento : Validation of form input

Magento’s frontend validation for form input fields is a nice feature. All it takes is for you to add some CSS classes to the input fields and then upon form submission validation is triggered that outputs, by default, red colored messages that point the possible validation failures etc. This validation is done on...

Read more

Magento : Code for creating grouped product

Magento : Code for creating grouped product

public function createGroupedProduct()     {         $sku = 'AL108';         $title = 'my test product';         $description = 'this is a description about the product...';           $product = new Mage_Catalog_Model_Product();    ...

Read more

Magento : Magento Certification Preparation – Some questions and answers

Magento :  Magento Certification Preparation – Some questions and answers

Please note that by preparing this you are not going to pass the exam, it’s just intented as a last day revision. You SHOULD go through each question yourself and dig into the Magento code base in order to pass this exam. This is JUST to make your life easier while you are stuck on some questions and want a backup...

Read more

Enable pdf extension on WYSIWYG for Magento

Enable pdf extension on WYSIWYG for Magento

 Came across other day the need to upload pdf files through the WYSIWYG tool on Magento. I’ve checked the native functionality and it allows by default only images (jpg, png, gif).   So, to change the initial behavior I opened the file app/code/core/Mage/Cms/etc/config.xml, which defines the...

Read more

Less vs Sass? It’s time to switch to Sass

Less vs Sass? It’s time to switch to Sass

  The CSS pre-processor debate Before I begin my highly opinionated tirade, let me just mention that I learned Less first. Less is great for beginners, it’s really easy and quick to set it up. It’s very similar to plain CSS, so writing it is intuitive. Compared to CSS, everything about LESS was very...

Read more

Cách cài đặt sử dụng SASS CSS

Cách cài đặt sử dụng SASS CSS

Nếu bạn đã nghe qua về LESS – một CSS Processcor hỗ trợ bạn viết CSS nhanh chóng và tiện lợi thì SASS cũng tương tự như vậy, nó cũng giúp bạn viết CSS cực kỳ nhanh chóng, có logic, dễ quản lý và cuối cùng là nó sẽ xuất ra định dạng CSS.   Nhưng...

Read more

Copying objects in PHP 5 using clone

Copying objects in PHP 5 using clone

That changed in PHP 5. Now when you assign an object to a new variable. The 2 variables remain inextricably linked. $object1->title = "Title One"; $object2 = $object1; $object2->title = "Title Two"; print $object1->title; // returns "Title Two"   In order to create an actual...

Read more

Magento: getSingleton() vs getModel() issue

Magento: getSingleton() vs getModel() issue

Mage::getModel() will always return a new Object for the given model:  /**  * Retrieve model object  *  * @link    Mage_Core_Model_Config::getModelInstance  * @param   string $modelClass  * @param   array|object $arguments  * @return  Mage_Core_Model_Abstract|false  */ public...

Read more

Magento : reset filter, order and clone

Magento : reset filter, order and clone

 public function getSelectCountSql() {        $this->_renderFilters();     $countSelect = clone $this->getSelect();     $countSelect->reset(Zend_Db_Select::ORDER);     $countSelect->reset(Zend_Db_Select::LIMIT_COUNT);     $countSelect->reset(Zend_Db_Select::LIMIT_OFFSET);  ...

Read more

Magento : Models, resource models, and collections

 Magento : Models, resource models, and collections

  Basic concepts of models, resource models, and collections A “model” is used to store data, and perhaps performs some business logics against that data. A “resource model” is used to interact with the database on behalf of the “model”. The “resource model” actually...

Read more

Magento : Listed all the filters query of sql

Magento : Listed  all the filters query of sql

 array("eq"=>'n2610') WHERE (e.sku = 'n2610') array("neq"=>'n2610') WHERE (e.sku != 'n2610') array("like"=>'n2610') WHERE (e.sku like 'n2610') array("nlike"=>'n2610') WHERE (e.sku not like&n...

Read more

Easy Debugging with NetBeans and XDebug

Easy Debugging with NetBeans and XDebug

 Basic steps to set-up debugging: 1. Download and install Xdebug  http://xdebug.org/docs/all 2. make changes to php.ini XDebug installed in Local Xampp in php.ini  (example uses standard  local xampp installation)   xdebug.remote_enable =1 xdebug.remote_hander =dbgp xdebug.remote_mode =...

Read more

Magento: How to enable Back Orders

Magento: How to enable Back Orders

Go to:Admin Panel -> System -> Configuration -> Catalog Tab -> Inventory -> Product Stock Options -> Backorders = Allow Qty Below 0 and Notify CustomerEdit Product to Qty = 0 and Stock Availability = In Stock   When you add the particular product to cart, the product is added to cart and you will...

Read more

Add security account before go to website

Add security account before go to website

      if ($_SERVER['PHP_AUTH_USER'] != 'admin' || $_SERVER['PHP_AUTH_PW'] != 'admin123') {         header('WWW-Authenticate: Basic realm="My Realm"');         header('HTTP/1.0 401 Unauthorized');         echo 'Access denied';  ...

Read more

Magento: How to add more extension of product image

Magento: How to add more extension of product image

Add config.xml  <config>     <adminhtml>         <events>             <catalog_product_gallery_prepare_layout>                 <observers>            ...

Read more

Magento : Code Import products to magento extremely quickly

Magento : Code Import products to magento extremely quickly

1) Copy Magmi.rar here to /lib folder 2) Configuration Open libMagmiconfmagmi.ini.default then change information to connect to DB and change its name 3) Call lib of Magmi in a block or helper require_once(Mage::getBaseDir() . "/lib/Magmi/inc/magmi_defs.php"); require_once(Mage::getBaseDir() . "/lib/Magmi/integration/inc/magmi_datapump.php");   4)...

Read more

PHP : Can't use method return value in write context when use empty

PHP : Can't use method return value in write context when use empty

 It's a limitation of empty() in PHP versions below 5.5. PHP doesn't have concept of emptyness. Values that evaluate to false are empty, values that evaluate to true are non-empty. It's the same thing. This code: $x = something(); if (empty($x)) … and this: $x = something(); if (!$x) … has always...

Read more

Magento: How to create a new payment method

Magento: How to create a new payment method

Here is small example which will explain how to create a simple Magento payment module. I hope that you know how to create magento module and I will skip this step. First of all, you have to create in etc folder config.xml file with next content: < ?xml version="1.0" encoding="UTF-8"?> <config>  ...

Read more

Magento : Add Notice

Magento : Add Notice

 If you’re wondering what I’m talking about, I’ve got an example for you in the image below: These messages, printed as notices, warnings or upon successful / unsuccessful action can be very useful. With this said, we have a few notification types in Magento we can use: Notice Mage::getSingleton(‘core/session’)->addNotice(‘Notice...

Read more

Magento mass product import

Magento mass product import

Problem: Importing a smaller amount of items is not a problem, but when you have a task to import 20 000+ items, the whole story falls apart.   Magento has inbuilt SOAP, but any actions with this system are simply too slow. Problem with the scripts are servers of various configurations. Most servers allow about...

Read more

Open cart : How to resize banner

Open cart : How to resize banner

Login to admin Go to : Extensions > Modules > Slideshow > Edit Change size to what you need

Read more

Open cart : How to add featured products?

Open cart : How to add featured products?

you can login to opencart admin > extention > module > features > under product > key in your product name >click at product > click save . you are done

Read more

Fix error scroll bar on mac, ipad, iphone

Fix error scroll bar on mac, ipad, iphone

Since OS X Lion, the scrollbar on websites are hidden by default and only visible once you start scrolling. Personally, I prefer the hidden scrollbar, but in case you really need it, you can overwrite the default and force the scrollbar in WebKit browsers back like this: ::-webkit-scrollbar { -webkit-appearance: none;...

Read more

Symfony : how to get current url in twig template??

Symfony : how to get current url in twig template??

 In symfony 2.3 you can use this:   {{ path(app.request.attributes.get('_route'),          app.request.attributes.get('_route_params')) }} And use like this   {{ path(app.request.attributes.get('_route'), my_router_params()|merge({'additional': 'value'}) }}   In...

Read more

Phân quyền tập tin và thư mục trong php dùng exec

Phân quyền tập tin và thư mục trong php dùng exec

Phân quyền cho thư mục: exec ("find /path/to/folder -type d -exec chmod 0750 {} +"); Phân quyền cho tập tin: exec ("find /path/to/folder -type f -exec chmod 0644 {} +");

Read more

Magento: Bestseller products aggregation

Magento: Bestseller products aggregation

There’s many ways of doing this. What I’ve found the most useful to me is to join product collection with the monthly bestseller aggregation. This way is fast and products can always be accessed even though the aggregation table is empty.   class Goweb_Damir_Block_Bestsellers extends Mage_Core_Block_Template {  ...

Read more

Magento: Sort Products by review

Magento: Sort Products by review

Step -1. For Advance shorting option you have to create new collection by overriding Collection class.Overrride the collection class(/app/code/core/Mage/Catalog/Model/Resource/Product/collection.php and create a new function <?php  public function sortByReview($dir){  $table = $this->getTable('review/review');  $entity_code_id...

Read more

Magento : How to show sort by most popular(most sold) products on product listing page?

Magento : How to show sort by most popular(most sold) products on product listing page?

we create a module to rewrite catalog module, lets create our config.xml at Goweb/Catalog/etc/config.xml: <config>     <modules>         <Goweb_Catalog>             <version>0.1.0</version>         </Goweb_Catalog>  ...

Read more

Magento : setData from layout to block

Magento : setData from layout to block

• It’s possible to insert variables into a block from a .xml file by using: <action method="setData"><name>category_id</name><value>3</value></action> Use the action tag with the method=”setData” attribute (setData method of block is called when the...

Read more

Magento : Set default payment

Magento : Set default payment

$this->getOnepage()->getQuote()->getBillingAddress()->setPaymentMethod('vaimo_klarna_invoice'); $payment = $this->getOnepage()->getQuote()->getPayment()->setMethod('vaimo_klarna_invoice'); $this->getOnepage()->getQuote()->save();

Read more

Symfony: Fix error symfony/icu v1.2.0 requires lib- icu >=4.4

Symfony: Fix error symfony/icu v1.2.0 requires lib- icu >=4.4

Enable  extension=php_intl.dll in php.ini Restart Apache and check again.

Read more

PHP : Sự khác nhau giữa thuộc tính Public, Private, Protected

PHP : Sự khác nhau giữa thuộc tính Public, Private, Protected

Protected: các thuộc tính các phương thức không thể truy xuất ra bên ngoài class, nó chỉ được gọi trong class và class kế thừa Private: các thuộc tính các phương thức không thể truy xuất ra bên ngoài class, nó chỉ được gọi trong phạm vi class Public: các...

Read more

Symfony : embed your controller action in twig

Symfony : embed your controller action in twig

{{ render(controller('LarryFrontendBundle:Article:recentArticles', { 'max': 9 })) }}

Read more

SYmfony : delete in mysql by doctine

SYmfony : delete in mysql by doctine

$em = $this->getDoctrine()->getEntityManager(); $repo = $em->getRepository('MyBundle:Product');   $product = $repo->findOneBy(array('field' => 'test'); $em->remove($product); $em->flush();   OR You can create a DQL query like this :   $query = $repository->createQuery('DELETE...

Read more

Symfony : Some command lines usefull

Symfony : Some command lines usefull

1) Clear cache : php app/console cache:clear --env=prod 2) Refresh assets css, js php app/console assets:install php app/console assetic:dump --watch Note : this is using for the case set use_controller: false (if true, system automatically refresh)  ref from : http://symfony.com/doc/2.1/cookbook/a...

Read more

Magento: Get Product object by SKU

Magento: Get Product object by SKU

$_sku = 'goweb'; $_productId = Mage::getModel('catalog/product')->getIdBySku($_sku); $_product = Mage::getModel('catalog/product')->load($_productId);

Read more

Git ignore exception

Git ignore exception

Git ignores folders if you write: /js but it can't add exceptions if you do: !/js/jquery or !/js/jquery/ or !/js/jquery/*   You must write:   /js/*  and only then you can except subfolders like this   !/js/jquery   Or you can use command line to add :   git add -f path/test/goweb.dll.   .gitignore...

Read more

GIT : Force Git to overwrite local files on pull

GIT : Force Git to overwrite local files on pull

git reset --hard HEAD git clean -f -d //delete file which not commited yet git pull --rebase origin <branch>

Read more

Magento : get tax rate of product

Magento : get tax rate of product

$product = Mage::getModel('catalog/product')->load($productId); $taxClassId = $product->getData("tax_class_id"); $taxClasses = Mage::helper("core")->jsonDecode(Mage::helper("tax")->getAllRatesByProductClass()); $taxRate = $taxClasses["value_" . $taxClassId];

Read more

Magento : Translation in js

Magento : Translation in js

1) put your translations in a jstranslator.xml in the etc directory of your module.  <jstranslator>     <some-unique-id translate="message" module="yourmodule">         <message>Some text to translate</message>     </some-unique-id>  ...

Read more

GIT : Generating SSH Keys

GIT : Generating SSH Keys

 We strongly recommend using an SSH connection when interacting with GitHub. SSH keys are a way to identify trusted computers, without involving passwords. The steps below will walk you through generating an SSH key and then adding the public key to your GitHub account. Step 1: Check for SSH keys First, we need to...

Read more