Skip to content

Instantly share code, notes, and snippets.

View zeljkoprsa's full-sized avatar

Željko Prša zeljkoprsa

View GitHub Profile
@zeljkoprsa
zeljkoprsa / Magento db Before Import
Created January 26, 2011 07:57
Code to insert at the top and the bottom of the exported "Magento db" to get properly imported again. By Branko Ajzele http://ajzele.net/moving-magento-site-from-development-to-live-server
Place these lines of SQL code on very top of the .sql file:
SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT;
SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS;
SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION;
SET NAMES utf8;
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('block-name')->toHtml() ?>
@zeljkoprsa
zeljkoprsa / CRLF to LF
Created January 28, 2011 13:11
On *nix
$ git config core.autocrlf false
@zeljkoprsa
zeljkoprsa / magento-category-navigation.phtml
Created February 18, 2011 12:42
Magento Category tree navigation
<?php
$categories = Mage::getModel('catalog/category')->load(1)->getChildren();
$categoryIDs = explode(',',$categories);
?>
<ul>
<?php foreach($categoryIDs as $categoryID): ?>
<li>
<?php $category = Mage::getModel('catalog/category')->load($categoryID);?>
<a href="<?php echo $category->getUrl()?>">
<?php echo $category->getName()?>
@zeljkoprsa
zeljkoprsa / new-products.xml
Created March 2, 2012 13:35
List New Products with toolbar (Grid/List, pagiantion the whole shebang )
<reference name="content">
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>8</category_id></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
</reference>
@zeljkoprsa
zeljkoprsa / remove_links.xml
Created March 27, 2012 07:10
Add to local.xml bp
@zeljkoprsa
zeljkoprsa / short-description-stripped.phtml
Created March 30, 2012 10:54
Short description stripped
<?php $_shortDescriptionStripped = $this->stripTags($_product->getShortDescription(), null , true); ?>
<?php echo Mage::helper('core/string')->truncate($_shortDescriptionStripped, '280') ?>
@zeljkoprsa
zeljkoprsa / clear-input.js
Created September 26, 2012 18:40
Input value clear using JavaScript
<input type="text" value="enter@email.com" name="email" id="email"
onblur="if (this.value == '') {this.value = 'enter@email.com';}"
onfocus="if (this.value == 'enter@email.com') {this.value = '';}" />
<?php $_product->getResource()->getTypeId(); ?>
<?php if($_product->getTypeId() == "simple"): ?> Simple <?php endif; ?>
<?php if($_product->getTypeId() == "grouped"): ?> Grouped <?php endif; ?>;
<?php if($_product->getTypeId() == "configurable"): ?> Configurable <?php endif; ?>
<?php if($_product->getTypeId() == "bundle"): ?> bundle <?php endif; ?>
@zeljkoprsa
zeljkoprsa / magento-canonical
Last active December 20, 2015 12:19
XML code that updates rel canonical for a single product in Magento. You should read this article for more detailed info: http://www.adurolabs.com/blog/technical/how-to-add-rel-canonical-in-magento #RTFM
<reference name="head">
<action method="addLinkRel">
<rel>canonical</rel>
<href>http://awesome.site.com/your-main-product</href>
</action>
</reference>