Skip to content

Instantly share code, notes, and snippets.

View jonatanrdsantos's full-sized avatar
🏠
Working from home

Jonatan Santos jonatanrdsantos

🏠
Working from home
View GitHub Profile
<?php
/**
* A simple fix for a shell execution on preg_match('/[0-9]\.[0-9]+\.[0-9]+/', shell_exec('mysql -V'), $version);
* The only edit that was done is that shell_exec('mysql -V') was changed to mysql_get_server_info() because not all
* systems have shell access. XAMPP, WAMP, or any Windows system might not have this type of access. mysql_get_server_info()
* is easier to use because it pulls the MySQL version from phpinfo() and is compatible with all Operating Systems.
* @link http://www.magentocommerce.com/knowledge-base/entry/how-do-i-know-if-my-server-is-compatible-with-magento
* @author Magento Inc.
*/
@jonatanrdsantos
jonatanrdsantos / mage-database.sh
Created October 30, 2015 16:05 — forked from diogobaracho/mage-database.sh
Magento common queries: mysqldump , import database, change admin user password, change site url, change cookie domain
#!/bin/sh
echo "Generate dump?(yes)"
read godump
if [ $godump = 'yes' ] || [ $godump = 'y' ]; then
read -p "mysql user: " YOUR_USER
read -p "mysql password: " YOUR_PASSWORD
read -p "mysql host: " YOUR_HOST
@jonatanrdsantos
jonatanrdsantos / load-payment-block-outside-magento.php
Created October 26, 2015 23:21
Load custom block outside magento
<?php
include_once "app/Mage.php";
umask(0);
Mage::app()->loadArea('frontend');
$layout = Mage::getSingleton('core/layout');
//load default xml layout handle and generate blocks
$layout->getUpdate()->load('default');
$layout->generateXml()->generateBlocks();
$ curl -s -o /dev/null -w "Status: %{http_code} Connect: %{time_connect} TTFB: %{time_starttransfer} Total time: %{time_total} \n" www.site-domain.com
Status: 200 Connect: 0,688 TTFB: 1,523 Total time: 2,756 
@jonatanrdsantos
jonatanrdsantos / Magento-errors-and-causes.md
Last active October 9, 2015 17:47
Magento errors and causes.

##Magento errors and causes

###Error: Not valid template file

CRIT (2): Not valid template file: frontend/base/default/template/path/to/template.phtml
@jonatanrdsantos
jonatanrdsantos / magento-update-state.php
Created October 5, 2015 17:46
Magento update state based in incrementalId
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'app/Mage.php';
Mage::app();
echo "Testando<br>";
$order = Mage::getModel('sales/order')->loadByIncrementId('100045842');
@jonatanrdsantos
jonatanrdsantos / magento-event-order-change-email.md
Last active October 5, 2015 17:28
Observe Magento order change event and send email

Observe Magento order change event and send email

XML code

<events>
    <sales_order_save_commit_after>
        <observers>
            <mail_status_change>
                <type>singleton</type>
 namespace_modulename/observer
@jonatanrdsantos
jonatanrdsantos / Magento-products-to-cart.php
Created October 1, 2015 20:25
Magento add products to cart via products IDS
<?php
public function addToAction()
{
$cart = Mage::getSingleton('checkout/cart');
$cart->addProductsByIds(
array(
$this->getRequest()->getParam('currentproduct'),
$this->getRequest()->getParam('relatedproduct')
@jonatanrdsantos
jonatanrdsantos / prototypejs-submit-form-via-axaj.html
Created October 1, 2015 19:34
submit form via axaj prototype.js
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Forms with Prototype</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript">
@jonatanrdsantos
jonatanrdsantos / magento-update-options.php
Created September 24, 2015 17:16
Magento Update Options
<?php
error_reporting(E_ALL);
require_once '../../../../../Mage.php';
Mage::app();
require_once './Garantia.php';
$productModel = Mage::getModel('catalog/product');