Coding

MAC OS X Xampp Access forbidden

MAC OS X Xampp Access forbidden

I have installed the XAMPP in my MAC.   And i just tryed to open a folder and it's returned a error 403: Access forbidden!   I read on foruns that i need to change the httpd archive, but, after the changes, no change, the error Access forbidden! on my folder/sites continues.   The http.conf that i have...

Read more

Xampp php, mysql in terminal macos

Xampp php, mysql in terminal macos

 To use the XAMPP PHP and other binaries found in /Applications/XAMPP/bin/ by default this is the correct entry for ~/.bash_profile   export XAMPP_HOME=/Applications/XAMPP export PATH=${XAMPP_HOME}/bin:${PATH} export PATH Load the changes with this (won't be needed next time you open a shell session):   source...

Read more

Simple Cache Busting for CSS and JS

Simple Cache Busting for CSS and JS

 If you update your site’s CSS or JS it is a good idea to force browsers to download the latest version. If you don’t then your visitor’s browser may well load a cached version of the CSS or JS which can result in broken pages. Busting the cache is also really convenient when you are pushing out changes...

Read more

Magento: Error default language in admin

Magento: Error default language in admin

Admin do not get default the language set:   Fix: check core_config_data have duplicate or having path column with value one “general” with value null

Read more

Please set available and/or protected paths list(s) before validation. | Create sitemap

Please set available and/or protected paths list(s) before validation. | Create sitemap

No invalid entries in the core_config_data table for these two configuration nodes

Read more

How do database indexes work? And, how do indexes help? Provide a tutorial on database indexes.

How do database indexes work? And, how do indexes help? Provide a tutorial on database indexes.

Let’s start out our tutorial and explanation of why you would need a database index by going through a very simple example. Suppose that we have a database table called Employee with three columns – Employee_Name, Employee_Age, and Employee_Address. Assume that the Employee table has thousands of rows. Now,...

Read more

How to grant remote access permissions to mysql server for user?

How to grant remote access permissions to mysql server for user?

If I do SHOW GRANTS in my mysql database I get   GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'      IDENTIFIED BY PASSWORD 'some_characters'      WITH GRANT OPTION If I am not mistaken, root@localhost means that user root can access the server only from localhost. How do I tell...

Read more

Mysql: string replace in mysql

Mysql: string replace in mysql

 UPDATE cookery_posts SET post_content = REPLACE(post_content, 'http://lenguyen.local/cookery/', 'http://gioancookery.com/n/');

Read more

Magento: remove all product imagesimages

Magento: remove all product imagesimages

 <?php require_once '../app/Mage.php'; Mage::app(); Mage::app()->getStore()->setId(Mage_Core_Model_App::ADMIN_STORE_ID);   $products = Mage::getModel('catalog/product')->getCollection();   $mediaApi = Mage::getModel("catalog/product_attribute_media_api");   foreach($products...

Read more

Magento: configure website by specific domain

Magento: configure website by specific domain

1) declare map map $http_host $magesite {         domain1.com website_code1;          domain2.com website_code2; } 2) MAGE_RUN_TYPE and MAGE_RUN_CODE   location ~ \.php$ {   #       fastcgi_split_path_info ^(.+\.php)(/.+)$;      ...

Read more

Magento: Best way to upgrade Magento from 1.4.2 to 1.9

Magento: Best way to upgrade Magento from 1.4.2 to 1.9

A direct upgrade from 1.4.x to 1.9.x might not be possible, but what I have found to produce good results for old database versions is an incremental upgrade to each new major version. You can find the last release of each version : 1.5,1.6,1.7,1.8 on the Magento download page. Test the upgrade on a dev server and start...

Read more

Magento: import products SOAP v2 API

Magento: import products SOAP v2 API

"additional_attributes" should not be including the following attributes.    protected $_defaultProductAttributeList = array(         'type_id',         'category_ids',         'website_ids',         'name',  ...

Read more

How to fix mysql error 1031 Table storage engine for '' doesn't have this option

How to fix mysql error 1031  Table storage engine for '' doesn't have this option

ERROR 1031 (HY000) at line 291001: Table storage engine for 'catalog_product_relation' doesn't have this option     Recently, I had the same problem with the import. PROBLEM This is probably due to the table option that you have in your CREATE TABLE DDL: ROW_FORMAT=FIXED Let’s check if there is...

Read more

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

 First, list MySQL processes using the ps command: ps aux | grep mysql And then kill the process sudo kill 56311

Read more

Use on click do not work after ajax call

Use on click do not work after ajax call

Use jQuery.on():   $( document ).on( 'click', 'a.like', function () {     // Do click stuff here } ); http://api.jquery.com/on/   You need to bind on to an element that will always be present. (document or some main wrapper div). Using on with the dynamic element will not work.

Read more

Retrieving Product Attributes from Magento's V2 API

Retrieving Product Attributes from Magento's V2 API

  // connect to soap server     $client = new SoapClient('http://magentoinstall.local/api/v2_soap?wsdl=1');       // log in     $session = $client->login('user', 'pass');       // product info     $attributes = new stdclass();     $attributes->attributes...

Read more

Error 404 whe upgrade magento to SUPEE-6788

Error 404 whe upgrade magento to SUPEE-6788

APPSEC-1034, addressing bypassing custom admin URL Note: This part of the patch is disabled by default. To protect non-default admin URLs against automated attacks, the patch must be enabled by changing the routing compatibility mode in configuration. Use "Enable Admin routing compatibility mode" under System...

Read more

Import file gzip to mysql

Import file gzip to mysql

gunzip < myfile.sql.gz | mysql -u root -p mydb

Read more

SoapFault exception: [HTTP] Not Found

SoapFault exception: [HTTP] Not Found

Go to http://domain.com/api/soap/?wsdl check the link in xml if you see  "http://mdomain.com/api.php/?type=soap" most likely the link does not working Solution :   Add to nginx configuration location /api p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color:...

Read more

Connect to a server by using SSH on Linux or Mac OS X

Connect to a server by using SSH on Linux or Mac OS X

This article provides steps for connecting to a cloud server from a computer running Linux or Mac OS X by using SSH. It also discusses generating an SSH key and adding a public key to the server. Introduction Secure Shell (SSH) is a protocol through which you can access your cloud server and run shell commands. You...

Read more

Magento: REST API nginx rewrite rule. api.php no executed

Magento: REST API nginx rewrite rule. api.php no executed

Error 404 when reaching https://child1-test.rkv.se/api/rest/products    You should write this in your nginx configuration:        location /api        {       rewrite ^/api/rest /api.php?type=rest last;       rewrite ^/api/v2_soap...

Read more

Magento: Got “Peer certificate cannot be authenticated with known CA certificates” while using Twitter OAuth with PHP PECL_OAuth

Magento: Got “Peer certificate cannot be authenticated with known CA certificates” while using Twitter OAuth with PHP PECL_OAuth

You can disable the sll checks:  $oauth->disableSSLChecks();   Ex  :  $oauthClient = new OAuth($consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1, $authType);  $oauthClient->enableDebug();   $oauthClient->disableSSLChecks();  

Read more

Ampps - Error message “Forbidden You don't have permission to access / on this server”

Ampps - Error message “Forbidden You don't have permission to access / on this server”

 Forbidden You don't have permission to access / on this server is actually the default configuration for an apache directory in httpd.conf.   # # Each directory to which Apache has access can be configured with respect # to which services and features are allowed and/or disabled in that # directory (and...

Read more

how to add vhost ampps

 how to add vhost ampps

 It is in \Ampps\apache\conf\extra folder  <VirtualHost magento.local:80> ServerName magento.local DocumentRoot /Users/larry/Documents/Documentroot/magento   </VirtualHost>

Read more

How to Increase Import Size Limit in phpMyAdmin

How to Increase Import Size Limit in phpMyAdmin

 Does anyone know if or how you can increase the import size limit in phpMyAdmin? Currently my server is limited to 50MB. Please note that this is not the same as the upload_max_filesize in php.ini. That value is set to 2MB. I need to import a table into one of my DBs and the phpMyAdmin restriction...

Read more

magento store views under sub folders with nginx

magento store views under sub folders with nginx

There are a couple of methods to achieve this, it just depends on which is more appropriate.   In our examples,   The domain is example.com The store view URI is mynewstore The store code is mynewstore_en The run type is store   Method 1   If don't mind sharing the entire root directory with...

Read more

Magento: Soap Api Failed To Load External Entity, php

Magento: Soap Api Failed To Load External Entity, php

Solved: Add simply a variable $params to disable API cache                  $params =  array(                     'trace' => 1,                     'exceptions' =>...

Read more

Magento: Difference Between setData() and addData()

Magento: Difference Between setData() and addData()

 setData overrides the existing data and can receive as parameter either a pair key-value either an array. if you set as parameters a pair key-value then $_data[key] becomes value. If you set as parameter an array $_data becomes that array overwriting what ever it contained previously. Example: $_data...

Read more

MySQL server has gone away - error 2006

MySQL server has gone away - error 2006

Error : #2006 - MySQL server has gone away Soln :- This error is occur due to due to expire of wait_timeout . Just go to mysql server check its wait_timeout : mysql> SHOW VARIABLES LIKE 'wait_timeout' mysql> set global wait_timeout = 600 # 10 minute or maximum wait time

Read more

Magento: Add stock data to product collection in Magento with require_stock_items flag

Magento: Add stock data to product collection in Magento with require_stock_items flag

  The shortest method to get stock data to your products collection is to add require_stock_items flag like this: PHP   $collection = Mage::getModel('catalog/product')->getCollection()     ->addAttributeToSelect(array('name', 'small_image', 'price'))     ->setFlag('require_stock_items',...

Read more

Magento: get option id from Label of Multi select

Magento: get option id from Label of Multi select

     function getOptionId($attributeCode, $optionLabel) {         $optionId = '';         $attr = Mage::getModel('catalog/product')->getResource()->getAttribute($attributeCode);         if ($attr->usesSource()) {      ...

Read more

Magento: Fatal error: Call to a member function setAttribute() on boolean

Magento: Fatal error: Call to a member function setAttribute() on boolean

Fatal error: Call to a member function setAttribute() on boolean in app\code\core\Mage\Eav\Model\Attribute\Data.php on line 80 when edit a customer of magento.   1) open app\code\core\Mage\Eav\Model\Attribute\Data.php on line 80 then add a log such as Mage::log($attribute->getAttributeCode(),null, 'test.log');...

Read more

How do I see the current encoding of a file in Sublime Text 2?

How do I see the current encoding of a file in Sublime Text 2?

  p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Arial; color: #242729; -webkit-text-stroke: #242729; background-color: #ffffff} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Arial; color: #242729; -webkit-text-stroke: #242729; background-color: #e1e3e5} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font:...

Read more

How to find encoding of a file in Unix via script

How to find encoding of a file in Unix via script

  p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 15.0px Arial; color: #242729; -webkit-text-stroke: #242729; background-color: #ffffff} span.s1 {font-kerning: none} span.s2 {font: 13.0px Consolas; font-kerning: none; background-color: #eff0f1} use file -i "path/filename"(linux) or file -I&n...

Read more

Search in vim

Search in vim

 1) Use grep grep -R "content_to_search" /path/to/directory grep -r --include=*.{cc,h} "hello" . OR grep hello *.h *.cc p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Consolas; color: #303336; -webkit-text-stroke: #303336; background-color: #eff0f1} span.s1 {font-kerning: none} This...

Read more

How do I switch between panes in split mode in Vim?

How do I switch between panes in split mode in Vim?

Ctrl-W, s will create a horizontal split. Ctrl-W, v will create a vertical split. Ctrl-W, direction will allow you to move among the panes. :ls will show your open buffers. :b <number> will open the specified buffer in the current pane.   you can use <ctrl> + w + w To switch the panes in order. A...

Read more

Magento: Magento left join collection Example

Magento: Magento left join collection Example

Following syntax is used for left joining two tables in magento :     //load collection  $collection = Mage::getModel('module/model_name')->getCollection(); $collection->getSelect()->joinLeft(Mage::getConfig()->getTablePrefix().'table_to_be_joined','main_table.table_field ='.Mage::getConfig()->getTablePrefix().'table_to_be_joined.table_field',array('field_name'));   Magento...

Read more

Magento: How to remove a specific url from Magento sitemap.xml?

Magento: How to remove a specific url from Magento sitemap.xml?

First copy file from app\code\core\Mage\Sitemap\Model\Sitemap.php to app\code\local\Mage\Sitemap\Model\Sitemap.php and after add bellow code at line number : 201   $collection->addFieldToFilter('identifier',array('neq'=>'coupon-partners'));   OR   Find bellow code in generateXml() function   ...

Read more

Magento: fix "Unknown cipher in list: TLSv1" when install a new extension from magento connect

Magento: fix

We fixed this by commenting out line 377 in downloader/lib/Mage/HTTP/Client/Curl.php //$this->curlOption(CURLOPT_SSL_CIPHER_LIST, 'TLSv1') There may be a setting that lets this pass through but we did not get that far.

Read more

Magento: Google Analytics Ecommerce tracking- success page

Magento: Google Analytics Ecommerce tracking- success page

<?php // GET SOME VALUES FOR TRACKING PIXELS     $_customerId = Mage::getSingleton('customer/session')->getCustomerId();      $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();      $order = Mage::getSingleton('sales/order');     ...

Read more

Mysql: Create new user and database

Mysql: Create new user and database

 To login into MySQL as root user, you can use:   mysql -u root -p   and then enter your MySQL password.   To login as another user, you will have to create that user first and grant him privileges.   Create the user using - change newuser to the username you want and password to your...

Read more

How to create and update drop down type attribute using SOAP API in Magento?

How to create and update drop down type attribute using SOAP API in Magento?

 <?php  require_once('app/Mage.php'); Mage::app(); class APIS  {     public function index()     {              try {             $optionLable = 'Red';             $optionValue...

Read more

Magento: Get Multi-Select Attribute Values text

Magento: Get Multi-Select Attribute Values text

$values=explode(',',$_product->getResource()->getAttribute('attribute_name')->getFrontend()->getValue($_product));$result=implode(",",$values);

Read more

PHP: conect to sftp

PHP: conect to sftp

I'd recommend using phpseclib, a pure PHP SSH2 implementation. Example:  <?php include('Net/SSH2.php'); $ssh = new Net_SSH2('www.domain.tld'); if (!$ssh->login('username', 'password')) {     exit('Login Failed'); } echo $ssh->exec('pwd'); echo $ssh->exec('ls -la'); ?...

Read more

PHP: fix error of path when using include files

PHP: fix error of path when using include files

set_include_path('/home/test/www/test/lib/'); require_once('phpseclib/Net/SFTP.php');   http://phpseclib.sourceforge.net/

Read more

PHP: fix error of path when using include files

PHP: fix error of path when using include files

set_include_path('/home/test/www/test/lib/'); require_once('phpseclib/Net/SFTP.php');   http://phpseclib.sourceforge.net/

Read more

Magento: Deleting All Products from a magento database with SQL

Magento: Deleting All Products from a magento database with SQL

It doesn’t happen often, but sometimes I need to wipe all products from a magento database during development. Either an import was written slightly off, or it was just full of test data and it’s cleaner to wipe the products instead of deleting them through the admin. A simple script for this found in a few...

Read more

Magento: Separate read and write databases in Magento

Magento: Separate read and write databases in Magento

 In your app/etc/local.xml fill <resources> in next way: <resources> <db> <table_prefix><![CDATA[]]></table_prefix> </db> <core_read> <connection> <use /> ...

Read more

Magento: get product by a attribute

Magento: get product by a attribute

 Mage::getModel('catalog/product')->loadByAttribute('sku', $item->getSku())

Read more