Skip to content

Instantly share code, notes, and snippets.

@rodrigowebjump
rodrigowebjump / Enable pdf extension in Magento Wysiwyg CMS
Created August 25, 2014 22:31
Enable pdf extension in Magento Wysiwyg CMS.
Create a new module and in config.xml do the follow:
<?xml version="1.0"?>
<config>
<modules>
<Company_Module>
<version>0.1.0</version>
</Company_Module>
</modules>
<adminhtml>
@rodrigowebjump
rodrigowebjump / detect_safari.js
Created August 6, 2014 17:32
Javascript detect if Safari
isSafari = navigator.vendor.indexOf("Apple")==0 && /\sSafari\//.test(navigator.userAgent); // true or false
@rodrigowebjump
rodrigowebjump / Plugin Wordpress para deixar o site em modo manutenção ou exibir página em breve
Created July 31, 2014 20:59
Plugin Wordpress para deixar o site em modo manutenção ou exibir página em breve
https://wordpress.org/plugins/site-is-offline-plugin/
@rodrigowebjump
rodrigowebjump / Magento - Script to remove unused images
Created July 31, 2014 20:47
Magento - Script to remove unused images Script para remover imagens não utilizadas
http://www.magpleasure.com/blog/free-imagecleanup-script-for-removing-unused-images.html
@rodrigowebjump
rodrigowebjump / Fix empty attributes showing as No
Created July 29, 2014 17:52
Fix empty attributes showing as "No" or "N/A". Corrigir atributos vazios exibindo "Não"
/app/design/frontend/default/[theme name]/template/catalog/product/view/attribute.phtml
<?php foreach ($_additional as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php } ?>
@rodrigowebjump
rodrigowebjump / Git arquivos acentuados no MAC
Created July 25, 2014 22:34
Git arquivos acentuados no MAC
Enable core.precomposeunicode on the Mac
git config --global core.precomposeunicode true
Then reclone the repository. For this to work, you need to have at least Git 1.7.12, which is bundled with Xcode 4.6.
git config --global core.quotepath off
Helper para exibir o trecho de um texto próximo a palavra-chave
http://bakery.cakephp.org/articles/grigri/2007/12/26/showing-a-text-excerpt-around-multiple-keywords
On a typical search results page, you want to display an excerpt of each matching item, showing the keywords. TextHelper::excerpt() works, but only for a single word/phrase. This helper finds the chunk of text containing as many keywords as possible.
<?php
class SummaryHelper extends AppHelper {
function excerpt($text, $words, $length=150, $prefix="...", $suffix = null, $options = array()) {
@rodrigowebjump
rodrigowebjump / CakePHP problemas de URL
Created July 23, 2014 12:11
CakePHP problemas de URL
Alguns servidores exigem a declaração abaixo para redirecionamento de url no .htaccess.
Você deve adicioná-la em todos arquivos .htaccess (/.htaccess, /app/.htaccess, /app/webroot/.htaccess).
RewriteEngine On
RewriteBase /caminho/da/app/
Referência: http://book.cakephp.org/2.0/en/installation/url-rewriting.html
@rodrigowebjump
rodrigowebjump / Consulta endereço a partir do CEP nos Correios.php
Created July 10, 2014 05:55
Consulta endereço a partir do CEP nos Correios
<?php
if(empty($_GET['cep'])){
exit;
}
$cep = preg_replace('/[^0-9]/', '', $_GET['cep']);
if(strlen($cep) != 8){
exit;
}
$orderId = YOUR_ORDER_ID;
$order = Mage::getModel(‘sales/order’)
->load($orderId);
If you have order increment id, you can load order in the following way:-
$orderIncrementId = YOUR_ORDER_INCREMENT_ID;
$order = Mage::getModel(‘sales/order’)
->loadByIncrementId($orderIncrementId);
Now, here is the code to change order status:-