Skip to content

Instantly share code, notes, and snippets.

View andresams's full-sized avatar
❤️
In a relationship with Magento 2

Andresa Martins andresams

❤️
In a relationship with Magento 2
View GitHub Profile
@andresams
andresams / tinydump
Created January 1, 2018 03:49 — forked from ceckoslab/tinydump
Simple PHP script, that creates a dump of Magento DB with smaller footprint ... the script just excludes the data some of the log tables, but keep the the schema of these tables.
<?php
define('DS', DIRECTORY_SEPARATOR);
function _getExtractSchemaStatement($sqlFileName, $db)
{
$dumpSchema = 'mysqldump' . ' ';
$dumpSchema .= '--no-data' . ' ';
$dumpSchema .= '-u ' . $db['user'] . ' ';
$dumpSchema .= '-p' . $db['pass'] . ' ';
$dumpSchema .= '-h ' . $db['host'] . ' ';
@andresams
andresams / exemplo-de-dados-enviados
Created March 8, 2016 14:09
Exemplo de como os dados das preferências são enviados para a API do Mercado Pago
Array
(
[client_id] => 277949545368493
[client_secret] => tLT5X4mXvu3QjmAbPgymzFdeLha4WkyR
[amount] => 306.8
[reason] => Pedido-15842
[currency_id] => BRL
[payment_method_id] => visa
[payer_email] => santosmanu123@gmail.com
[external_reference] => 15842
@andresams
andresams / trecho-mercado-pago-preferencias.php
Created March 8, 2016 13:59
Código do envio de dados para API do Mercado Pago.
<?php
#Código de seleção destes dados do cliente e inserção do pedido acima
$data['client_id']=Configuration::get('MERCADOC_CLIENT_ID');
$data['client_secret']=Configuration::get('MERCADOC_CLIENT_SECRET');
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, 'MercadoPago Prestashop Brasil v2');
@andresams
andresams / new_gist_file.php
Created December 22, 2015 12:39
Magento get html static block by ID inside of .phtml files
<?php
echo $this->getLayout()->createBlock('cms/block')->setBlockId('block_identifier')->toHtml();
?>
@andresams
andresams / get-store-info-magento.php
Created November 30, 2015 07:40
Gets current store information from Magento. Store ID, store name, store status, store code, website id, store group id, store sort order, store locale, store home url
<?php
// Gets the current store's details
$store = Mage::app()->getStore();
// Gets the current store's id
$storeId = Mage::app()->getStore()->getStoreId();
// Gets the current store's code
@andresams
andresams / opencart_redirect_url.php
Created November 4, 2015 18:43
Redireciona Opencart para uma url ou módulo dentro de um controlador
<?php
#Sempre adiciona o token no final da URL
$url .='token=' . $this->session->data['token'];
#gera url para determinada ação do controlador do módulo
$url = $this->url->link('catalog/product/edit', $url , 'SSL');
#redireciona na resposta
$this->response->redirect($url);
@andresams
andresams / magento_index.sh
Last active November 2, 2015 18:19
Atualizar índices do Magento manualmente via SSH. Útil quando os índices ficam travados em "processing" (processando)
#Executar comandos individualmente na shell
php shell/indexer.php -reindex catalog_product_attribute
php shell/indexer.php -reindex catalogsearch_fulltext
php shell/indexer.php -reindex catalog_category_flat
php shell/indexer.php -reindex cataloginventory_stock
php shell/indexer.php -reindex catalog_category_product
php shell/indexer.php -reindex catalog_product_price
php shell/indexer.php -reindex tag_summary
php shell/indexer.php -reindex catalog_url
@andresams
andresams / zopim.js
Created November 2, 2015 01:19
Abre uma janela com o chat do zopim
function abrir_zopim(chave_zopim)
{
var myWindow = window.open("https://v2.zopim.com/widget/popout.html?key="+chave_zopim,"","width=500,height=500");
}