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 / 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

function getBrandName() {
var location = window.location.href,
taskNumber = location.substr(location.lastIndexOf('/')+1)
taskName = document.getElementById("summary-val").innerText.toLowerCase().replace(/\s+\|\s+/g, '|').replace(/[^a-z0-9]/g, '-').replace(/:/g, '').replace(/\|/g, '').replace(/-+/g, '-')
;
console.log(taskNumber +'-'+ taskName);
}
getBrandName();
@tuanphpvn
tuanphpvn / LOGIN WITH PASS SU -
Last active August 3, 2016 14:42
Hard code Login with your password
#!/bin/sh
echo 'XXXX' | sudo -S su -
sudo su born <<'EOF'
cd /var/www/XXX
git pull origin master
EOF
~
DESCRIBE `enterprise_url_rewrite_redirect`;
INSERT INTO `enterprise_url_rewrite_redirect` (`identifier`, `target_path`, `options`, `description`, `category_id`, `store_id`) VALUES ('browse/by-packaging.html', 'browse/package', NULL, NULL, '28', '3');
INSERT IGNORE INTO `enterprise_url_rewrite_redirect_cl` (`redirect_id`) VALUES (NEW.`redirect_id`);
SELECT `enterprise_mview_metadata`.* FROM `enterprise_mview_metadata` WHERE (`enterprise_mview_metadata`.`table_name`='enterprise_url_rewrite_redirect');
START TRANSACTION;
DELETE `ur` FROM `enterprise_url_rewrite` AS `ur`
INNER JOIN `enterprise_url_rewrite_redirect_rewrite` AS `r` ON r.url_rewrite_id = ur.url_rewrite_id WHERE (ur.is_system = 0) AND (ur.entity_type = 1) AND (r.redirect_id = 12);
INSERT INTO `enterprise_url_rewrite` (`request_path`, `target_path`, `guid`, `is_system`, `identifier`, `value_id`, `store_id`, `entity_type`) SELECT CONCAT(r.identifier, CASE WHEN ur.inc IS NULL OR `m`.`value` = 1 THEN '' ELSE CONCAT('-', ur.inc) END) AS `request_pat
@tuanphpvn
tuanphpvn / MAGENTO - select orgin country.js
Last active August 3, 2016 14:46
Select list country in Magento 1 by country code #Magento #Automatic #CountryCode
<script>
jQuery.each(jQuery("#general_country_allow option"), function(){
var $this = jQuery(this), val = $this.val();
var arr = ["GB", "FR", "IT", "DE", "NL", "ES", "SE", "DK", "BE", "AT", "IE", "PT", "PL"];
if(jQuery.inArray(val, arr) !== -1) {
$this.attr("selected", "selected");
}
@tuanphpvn
tuanphpvn / PARSER -CSV TO XML.php
Last active August 3, 2016 14:48
Functions which convert from csv to xml #XML #PHP #CSV #Convert
<?php
class convertCsvToXml {
protected $arrCol = ["a", "b", "c"];
protected $arrXPath = [
0 => "product-families/product-family[name='{{f-name}}']/product-models",
1 => "product-families/product-family[name='{{f-name}}']/product-models/product-model[name='{{m-name}}']/accessory-types",
2 => "product-families/product-family[name='{{f-name}}']/product-models/product-model[name='{{m-name}}']/accessory-types/accessory-type[name='{{a-name}}' or sku='{{sku}}']",
];
@tuanphpvn
tuanphpvn / GET DATE TIME -CUSTOM TIMEZONE.php
Last active August 3, 2016 14:50
Override datetime of Mage_Core_Model_Date #Magento, #Date
<?php
/**
* Features attributes helper
*
* @package timezone
* @author tuanphpvn@gmail.com
*/
class BC_Future_Model_Date extends Mage_Core_Model_Date
{
@tuanphpvn
tuanphpvn / MAGENTO -PAYPAL -FORM PAYMENT STANDARD.html
Last active August 3, 2016 14:51
Paypal submit form #Paypal, #Magento, #Example
<html><body>You will be redirected to the PayPal website in a few seconds.<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" id="paypal_standard_checkout" name="paypal_standard_checkout" method="POST"><div><input name="form_key" type="hidden" value="m4Ux3YIWUZc3biqa" /></div><input id="business" name="business" value="tuan.nguyen-meerchant@bluecomgroup.com" type="hidden"/>
<input id="invoice" name="invoice" value="145000024" type="hidden"/>
<input id="currency_code" name="currency_code" value="USD" type="hidden"/>
<input id="paymentaction" name="paymentaction" value="sale" type="hidden"/>
<input id="return" name="return" value="http://rsmagento_1_14_01.app/paypal/standard/success/" type="hidden"/>
<input id="cancel_return" name="cancel_return" value="http://rsmagento_1_14_01.app/paypal/standard/cancel/" type="hidden"/>
<input id="notify_url" name="notify_url" value="http://rsmagento_1_14_01.app/paypal/ipn/" type="hidden"/>
<input id="bn" name="bn" value="Magento_Cart_Enterprise" type="hidden"/>
<inp
@tuanphpvn
tuanphpvn / MAGENTO - Replace all email when send.tex
Last active August 3, 2016 14:52
Debug send mail , #Magento1, #Mail, #Debug
1. Go to Zend_Mail_Transport_Sendmail::_sendMail
2. input:
Mage::log($this->recipients, Zend_Log::INFO, "email.log");
$this->recipients = preg_replace("/<([^>]*)>/", "<tuanphpvn@gmail.com>", $this->recipients );