Skip to content

Instantly share code, notes, and snippets.

View tuanphpvn's full-sized avatar

christian tuanphpvn

View GitHub Profile
@tuanphpvn
tuanphpvn / 0_reuse_code.js
Last active August 29, 2015 14:12
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@tuanphpvn
tuanphpvn / backend_uploadgallery.php
Last active August 4, 2016 01:38
Pl Upload multiple #Wordpress #PlUpload
require_once(ABSPATH . "wp-admin" . '/includes/image.php');
require_once(ABSPATH . "wp-admin" . '/includes/file.php');
require_once(ABSPATH . "wp-admin" . '/includes/media.php');
if(!$_FILES) {
wp_die(''); // Do nothing
}
// check max allowed
$max_upload_gal_img = of_get_option(Apollo_DB_Schema::_MAX_UPLOAD_GALLERY_IMG, Apollo_Display_Config::MAX_UPLOAD_GALLERY_IMG);
@tuanphpvn
tuanphpvn / wp.jscropt.js
Last active August 4, 2016 01:36
JScrop upload and drop image in wordpress
/*
$primary_img_sel: main image you want to drop
boxWidth: box contain image. which you want. I usally less than image size
boxHeight: same boxWidth
trueSize: True size of image
keySupport: there are on bug in current i write. When i press image it alwasy go to bottom of page
onChange: when we click on the image. I will change coordinate and width and height. c.w, c.h, c.x, c.y, c.x2, c.y2
*/
$primary_img_sel.Jcrop({
@tuanphpvn
tuanphpvn / gist:580a8ccb45b33ac9b3ba
Last active August 29, 2015 14:26 — forked from quafzi/gist:2234563
Magento Snippets

Magento Snippets

Find all dispatched event observers

grep -r Mage::dispatchEvent /path/to/your/Magento/* > events.txt

Find all translatable strings

@tuanphpvn
tuanphpvn / change_param_in_query_by_key_value.js
Last active August 4, 2016 01:18
Change param in query #Javascript #Params
change_param_in_query_by_key_value = function(key, value, query) {
var arrParams = query.parseQuery();
if(typeof arrParams[key] === "undefined") {
return query;
}
var _value = arrParams[key], _arr = _value.split('-');
var position_occur_in_value_query = $j.inArray(value, _arr);
if(position_occur_in_value_query === -1) {
return query;
@tuanphpvn
tuanphpvn / magento_tree_category_delete.php
Last active August 4, 2016 00:57
Delete category with a name #Magento #Category
<?php
$deleteCatByName = function($catname) {
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
if ($ids){
foreach ($ids as $id){
@tuanphpvn
tuanphpvn / gist:97ccd098475264f4f512
Last active August 4, 2016 00:56
Select all checkbox. What you need to add data-ride="ap-checkboxall" to the select all checkbox and point to his child. That zit #Widget
(function($) {
var $arr_checkall = $('[data-ride="ap-checkboxall"]');
/* bind checkall */
$arr_checkall.click(function() {
var $this = $(this),
_data = $this.data();
$(_data.child_selector).prop('checked', $(this).is(':checked'));
@tuanphpvn
tuanphpvn / gist:bb57303bae49c142e16e
Last active August 4, 2016 00:55
Convert current database (not support utf8) to Support UTF8 #Mysql #UTF8
mysqldump -u root -pyourpass --default-character-set=latin1 -c --insert-ignore --skip-set-charset your_database > dev.db
for i in dev; do iconv -f ISO-8859-1 -t UTF-8 <$i.db >${i}8.db; done
for i in *8.db; do perl -pi -w -e 's/CHARSET=latin1/CHARSET=utf8/g;' $i; done
for i in your_database; do mysql --user=root --password=yourpassword --execute "DROP DATABASE $i; CREATE DATABASE $i CHARACTER SET utf8 COLLATE utf8_general_ci;"; done
mysql --user=root --password=yourpassword --max_allowed_packet=16M --default-character-set=utf8 your_database < dev8.db
@tuanphpvn
tuanphpvn / MAGENTO - create category by fastimport extension.php
Last active August 4, 2016 00:53
create category by fastimport extension #Magento #IMport #Category
<?php
$createCategory = function() {
$data = array();
$arrKey = array(
'Men',
'Men/Shirts',
'Men/New Arrivals',
'Men/Tees, Knits and Polos',
@tuanphpvn
tuanphpvn / MAGENTO- Create multiple attribute set by array.php
Last active August 4, 2016 00:52
Create list attribute set by Array #Magento #Attributeset
<?php
$createAttributeSet = function($arrAttributeSetName) {
$entityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
$attributeSetDefault = Mage::getModel('eav/entity_attribute_set')->getCollection()
->addFieldToFilter('attribute_set_name', 'Default')
->addFieldToFilter('entity_type_id', $entityTypeId)
->setPageSize(1)->getFirstItem();