Coding

PHP: Merge array pefect, fix error lost key

PHP: Merge array pefect, fix error lost key

function mergeArray($arr1,$arr2) {     if(!is_array($arr1))   $arr1 = array();     if(!is_array($arr2))   $arr2 = array();     $keys1 = array_keys($arr1);     $keys2 = array_keys($arr2);     $keys  = array_merge($keys1,$keys2);     $vals1 =...

Read more

Magento : How to add pager custom

Magento : How to add pager custom

It's actually quite simple.   In the main block that calls your collection to render, add the following: protected $_itemCollection; protected function _construct() {         parent::_construct();         $currentPage = $this->getRequest()->getParam('p', 1);   ...

Read more

Magento: Inject Body Class via Layout XML

Magento: Inject Body Class via Layout XML

<reference name="root">   <action method="addBodyClass"><classname>my-body-class</classname></action> </reference>

Read more

Symfony : Config APC

Symfony : Config APC

Link download : http://downloads.php.net/pierre/ copy to php/ext php_apc.dll, then add this to php.ini extension=php_apc.dll   [APC] apc.enabled = 1 apc.shm_segments = 1   ;Fix eror require_once(): Cannot redeclare class pma_recenttable   apc.include_once_override = 0 apc.canonicalize = 0 apc.stat...

Read more

Magento : get Request param in a event

Magento : get Request param in a event

$request    = $observer->getEvent()->getData('front')->getRequest(); $parameter  = $request->yourparametername;

Read more

Magento : Remove cache in the block

Magento : Remove cache in the block

Add this function in your block :   protected function _construct()     {         parent::_construct();         $this->addData(array(                 'cache_lifetime'    => 0,        ...

Read more

Magento : Magento add Js to the footer

Magento : Magento add Js to the footer

 For Magento v1.7+ (need to test in older versions);   1 - create an template file in page/html/footer/extras.phtml with this content:   <?php echo $this->getCssJsHtml() ?>   2 - Add this html node to your layout xml:   <reference name="before_body_end"> <block...

Read more

Beautiful Template admin panel bootstrap3

Beautiful Template admin panel bootstrap3

There are Full features about panel, login, register, grid   Link download :  http://www.bootstrapstage.com/devoops/

Read more

Magento : Share cart between websites ( the way 2)

Magento : Share cart between websites ( the way 2)

'Use SID on Frontend' must be st to 'Yes' (System->Configuration->Web->Session Validation Settings) Approach:    Magneto already allows you to keep the quote (cart) between store views from the same website. I tried to manipulate this feature into letting me keep the cart between all websites (store...

Read more

Magento : HOW TO SHARE MAGENTO CART BETWEEN SEVERAL MAGENTO MULTI-STORES

Magento : HOW TO SHARE MAGENTO CART BETWEEN SEVERAL MAGENTO MULTI-STORES

You need multi-stores configured in your Magento and you want to have single cart for all multi-stores this article All your multi-stores will be not separate websites, they all will have single cart (share cart content between multi-stores).   1) Share the cart content between Magento multi-store websites.   Magento...

Read more

N98-magerun : Provides some handy tools for magento developers

N98-magerun : Provides some handy tools for magento developers

Some commands: Dump database Direct dump with mysqldump: n98-magerun.phar database:dump The command will ask for the dump filename. Only the mysqldump command: n98-magerun.phar database:dump --only-command Global Config Commands Generate local.xml file n98-magerun.phar local-config:generate Dump global xml config n98-magerun.phar...

Read more

Html : Difference between \<\article\> and \<\section\> tags in html 5

Html : Difference between \<\article\> and \<\section\> tags in html 5

<section> tends to be used for grouping things. Their natural headers are typically plural. e.g. "Cars for Sale"   <article> is for units of content. Their natural headers are usually a title for the whole of the text that follows. e.g. "My New Car"   So, if you're not grouping...

Read more

Magento: How to get admin user id, name, username, email, so on ...

Magento: How to get admin user id, name, username, email, so on ...

Here is a quick code to get the admin user’s data (id, name, username, email, password, etc). $userArray = Mage::getSingleton('admin/session')->getData(); $user = Mage::getSingleton('admin/session'); $userId = $user->getUser()->getUserId(); $userEmail = $user->getUser()->getEmail(); $userFirstname...

Read more

Mac : how to update hosts file

Mac : how to update hosts file

1) Open terminal 2) run this command :  sudo nano /private/etc/hosts

Read more

How TO run Selenium with PHPUnit on windowns, Linux

How TO run Selenium with PHPUnit on windowns, Linux

 1.  Summary -          Selenium is an automation testing tool which is opensoure -          Selenium is a suite of tools specifically for testing web applications. -         ...

Read more

Magento : Change Default Option Text for Configurable Products

Magento : Change Default Option Text for Configurable Products

Update Product JSON   In the configurable.phtml template, an array of settings is being passed into a JavaScript class for rendering options. This is where a lot of solutions to this problem go wrong: we don’t want to edit the JavaScript or core settings file, and well, extending is messy and a hassle. Instead...

Read more

PHP : Check if directory exists

PHP : Check if directory exists

$dirname = $_POST["search"]; $filename = "/folder/" . $dirname . "/";   if (!file_exists($filename)) {     mkdir("folder/" . $dirname, 0777);     echo "The directory $dirname was successfully created.";     exit; } else {  ...

Read more

Cross domain AJAX that is cross browser as well

Cross domain AJAX that is cross browser as well

AJAX with JSON request Be sure your request is a JSON request, below is an example: $.ajax({     url: "http://your.other.domain.com/here/?",     type: "GET",     cache: true,     contentType: "application/json",     dataType: "json",  ...

Read more

Magento : get all Invoice data

Magento : get all Invoice data

$orders_invoice = Mage::getModel("sales/order_invoice")->getCollection(); foreach($order_invoice as $val){ $invoice = $val->getData();  $order = Mage::getModel('sales/order')->load($invoice["order_id"]); $orderdata = $order->getData(); $totaldue = $orderdata['total_due']; $grandtotal...

Read more

Magento : Fix error magento

Magento : Fix error magento

Fix error Fatal error: Declaration of Zend_Pdf_FileParserDataSource_File::__construct() must be compatible with Zend_Pdf_FileParserDataSource::__construct() 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...

Read more

Gửi email từ localhost bằng Mercury Mail

Gửi email từ localhost bằng Mercury Mail

Việc gửi mail từ localhost sẽ trở nên dễ dàng với bộ công cụ XAMPP. http://www.apachefriends.org/en/xampp.html Cachs cấu hình gửi email từ localhost sử dụng công cụ MercuryMail có sẵn trong XAMPP. Sau khi tải về, bung nén chẳng hạn vào E:xampp => Bạn có E:xamppxampphtdocs. Mở...

Read more

Magento : Only show tab for specific product type only not for all product type

Magento : Only show tab for specific product type only not for all product type

 public function canShowTab()     {         $allowedProductTypes = array(             Mage_Catalog_Model_Product_Type_Grouped::TYPE_CODE,             Mage_Downloadable_Model_Product_Type::TYPE_DOWNLOADABLE,    ...

Read more

Hàm clone trong PHP

Hàm clone trong PHP

Hàm này dùng để sao chép  một đối tượng từ một đối tượng khác Ví dụ 1: Sao chép một đối tượng không sử dụng phương thức clone <?php require_once 'ConMeo.class.php';   $conMeoA = new ConMeo(); $conMeoA->setName("Tiger"); $conMeoA->setAge(3); $conMeoA->setColor('Vàng');     $conMeoB...

Read more

Add message magento at checkout/onepage:

 Add message magento at checkout/onepage:

 Add message magento at checkout/onepage:   1) Add to load layout to _initLayoutMessages in controller   ->_initLayoutMessages('checkout/session')             ->_initLayoutMessages('catalog/session')   2) change from true to false at goback $this->_getSession()->getMessages(false);...

Read more

Xcentos : Fix error Implicit Conversion from NSInteger to NSString not allowed in ARC

Xcentos : Fix error Implicit Conversion from NSInteger to NSString not allowed in ARC

open "Build phases" -> "Compile sources" select files with "left_mouse" + "cmd" (for separated files) or + "shift" (for grouped files - select first and last) press "enter" paste -fno-objc-arc press "enter"...

Read more

Magento : get List show most view products, most sell product

Magento : get List show most view products,  most sell product

Step 1: Create a file app/code/local/Mage/Catalog/Block/Product/Mostviewed.php and add the following lines of code in it   class Mage_Catalog_Block_Product_Mostviewed extends Mage_Catalog_Block_Product_Abstract{     public function __construct(){         parent::__construct();  ...

Read more

Magento : get current category and product

Magento : get current category and product

$hb = ''; $current_category = Mage::registry('current_category'); if(!is_object($current_category)) {     $current_product = Mage::registry('current_product');     if(is_object($current_product))     {         $categories = $current_product->load($current_product->getId())->getCategoryIds();  ...

Read more

Magento : Get table prefix

Magento : Get table prefix

$prefix = Mage::getConfig()->getTablePrefix(); echo $prefix;

Read more

Magento : Cookie magento

Magento : Cookie magento

require 'Mage.php'; Mage::app(); $cookie = Mage::getSingleton('core/cookie'); $cookie->set('cookiename', 'cookievalue' ,time()+86400,'/');

Read more

Magento : Change style of configurable product option dropdowns into selectable links or radio buttons

Magento : Change style of configurable product option dropdowns into selectable links or radio buttons

Copy to view.phml then custom it. Script below converts the dropdowns into links and shows selected    <script type="text/javascript"> function replaceDropDowns() {     jQuery('.product_attribute_option_link').remove();     jQuery('#selected_combination').text('');...

Read more

Magento : Code update shipping table rate

Magento : Code update shipping table rate

$shippingCode = 'tablerate_bestway'; $country = 'DK'; $address = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress(); $address->setCountryId($country); $address->setShippingMethod($shippingCode)->setCollectShippingRates(true); Mage::getSingleton('checkout/session')->g...

Read more

Magento : Auto update shipping

Magento : Auto update shipping

class Update_Checkout_Model_Observer { private $_shippingCode = 'tablerate_bestway'; private $_country = 'SE'; public function addShipping($params = null) { if (Mage::registry('checkout_addShipping')) { Mage::unregister('checkout_addShipping'); return; }   Mage::register('checkout_addShipping',...

Read more

Magento : Convert Price from Current Currency

Magento : Convert Price from Current Currency

 <?php $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode(); $price = 100;   // convert price from current currency to base currency $priceOne = Mage::helper('directory')->currencyConvert($price, $currentCurrencyCode,...

Read more

Magento : Set currency when creating order

Magento : Set currency when creating order

$currencyCode = "..."; $quote = $this->getOnepage()->getQuote(); $quote->setBaseCurrencyCode($currencyCode); $quote->setQuoteCurrencyCode($currencyCode); $quote->setCurrency($currencyCode);

Read more

Xdebug for Magento – Local

Xdebug for Magento – Local

This article was written using Notepad++, Eclipse Indigo IDE with the PHP Development Tools (PDT), Xdebug running on a local Xampp server and 64 bit Windows 7. Documentation how to install and integrate Xdebug, Eclipse and Magento, was pretty extensive but too confusing since setting Xdebug form Magento is really simple.   1....

Read more

Magento : Fix error Apache HTTP server has stopped working when install Magento

Magento : Fix error Apache HTTP server has stopped working when install Magento

Download this: http://windows.php.net/downloads/snaps/php-5.2-win32-VC6-x86-latest.zip   Unzip, then copy libmysql.dll into xamppapachebin and xamppphp. Restart apache and you should be good.

Read more

Meta work good for responsive

Meta work good for responsive

Put it into <head> tag :  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />

Read more

Magento : Create Customize Form Validation Messages

Magento : Create Customize Form Validation Messages

In Magento, if you want to change the build-in validation messages (like : “This is a required field.” or “We need this information”), then you can simply do that by the following way:   Suppose you’ve the following text-box in you form:   <label for="name">Name...

Read more

Magento : Rewrite URL of module

Magento : Rewrite URL of module

Open your config.xml file of your module and add this code inside the <global> tag. 1 2 3 4 5 6 7 <rewrite>         <fancy_url> ...

Read more

Sublime Text 3 v3059 full – Công cụ viết code chuyên nghiệp

Sublime Text 3 v3059 full – Công cụ viết code chuyên nghiệp

Sublime Text phiên bản mới 3059 07-01-2014 là một trong những công cụ dùng để viết code php, html, và các ngôn ngữ lập trình khác,… Với nhiều ưu điểm vượt trội hơn so với Notepad++ (plus). Ngoài các tính năng như tự hiển thị màu code cho dễ xem như...

Read more

Error php.exe is not recognized

Error php.exe is not recognized

If you get the error  php.exe is not recognized as an internal or external command   When you try to create the new framework then you need to add php.exe's location to your system path.   On Windows XP goto    Control Panel > System > Advanced > Environment Variables > System...

Read more

Zend : how to delete session automatically after ther the time expires

Zend : how to delete session automatically after ther the time expires

resources.session.name = "ZendSession" resources.session.save_path = APPLICATION_PATH "/../tmp/session" resources.session.remember_me_seconds = 360 resources.session.gc_maxlifetime = 360 resources.session.cookie_lifetime = 360 resources.session.cache_expire = 360   About the deleting: You...

Read more

Magento : New Product Collection With Pagination

Magento : New Product Collection With Pagination

step 1: In app/code/local/Mage/catalog/product/newall.php create block file that extend to Mage_Catalog_Block_Product_List <?php class Mage_Catalog_Block_Product_Newall extends Mage_Catalog_Block_Product_List {      protected function _getProductCollection()    {    if (is_null($this->_productCollection))...

Read more

Cool responsive image slider with thumbnail carousel

Cool responsive image slider with thumbnail carousel

 This entire gallery resizes along with your browser (to fit 50% of its width), the thumbnail carousel below the large image also resizes and (if necessary) changes the number of visible items. This carousel is created for your inspiration, using only the jQuery-library and the jQuery.carouFredSel-plugin. You may...

Read more

Top 10 Free Responsive Image Galleries/Slideshows

Top 10 Free Responsive Image Galleries/Slideshows

 If your website relies heavily on images, then having an image gallery is a great way to showcase your content on your website. Having said that, this idea may also backfire if visitors are coming from a mobile or touch device. Mobile users deserve some love too, hence the purpose of today’s post. There are...

Read more

Cách tạo plugin jQuery đơn giản nhất, dễ hiểu nhất

Cách tạo plugin jQuery đơn giản nhất, dễ hiểu nhất

Để plugin chạy được bạn phải thêm thư viện jQuery vào tài liệu html của bạn. Hãy nhớ lấy điều này!. Ví dụ 1: Xây dựng plugin hello, alert ra màn hình chữ hello world  $.fn.hello = function() {     alert('Hello world'); } Trong đó  $ là viết tắt...

Read more

Zend Framework 2.2: Hướng dẫn cài đặt ứng dụng đầu tiên

Zend Framework 2.2: Hướng dẫn cài đặt ứng dụng đầu tiên

Lưu ý: + Toàn bộ cấu hình và mã nguồn của bài này đều đã test trên phiên bản 2.2. Đối với những phiên bản cũ hơn thì sẽ không chạy được (kể cả phiên bản 1.x). + PHP yêu cầu trong hệ thống là từ 5.3.3 trở lên. Để chạy tốt, tôi khuyến cáo sử...

Read more

SQL : Fix error Lock wait timeout exceeded?

SQL : Fix error Lock wait timeout exceeded?

You should consider increasing the lock wait timeout value for InnoDB by setting the innodb_lock_wait_timeout, default is 50 sec   mysql> show variables like 'innodb_lock_wait_timeout'; +--------------------------+-------+ | Variable_name            | Value | +--------------------------+-------+ |...

Read more

Magento : Add filter to select the cms pages list

Magento :  Add filter to select the cms pages list

 $collection = Mage::getModel('cms/page')->getCollection()               ->addStoreFilter($storeId)               ->addFieldToFilter('is_active',1)               ->addFieldToFilter('identifier',a...

Read more

Magento : Module change currency symbol

Magento : Module change currency symbol

Lets you manage price display in an easy way: show custom currency symbol, number of decimals, etc. http://www.magentocommerce.com/magento-connect/et-currency-manager.html

Read more