Skip to content

Instantly share code, notes, and snippets.

View RowanBurgess-zz's full-sized avatar

RowanBurgess-zz

View GitHub Profile
@RowanBurgess-zz
RowanBurgess-zz / .htaccess
Created April 29, 2016 18:44 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
<?php
//Possible color value
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color'); //"color" is the attribute_code
$allOptions = $attribute->getSource()->getAllOptions(true, true);
foreach ($allOptions as $instance) {
$id = $instance['value']; //id of the option
$value = $instance['label']; //Label of the option
}
?>
<?php
//include Magento app
require_once 'app/Mage.php';
//initialize Magento
Mage::app();
//call Magento model or functions (this example get unsubscription link for customer)
$email = "[email protected]";
$unSubLink = Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getUnsubscriptionLink();
<?php
$categories = Mage::getModel('catalog/category')->getCollection()
->addAttributeToSelect('id')
->addAttributeToSelect('name')
->addAttributeToSelect('url_key')
->addAttributeToSelect('url')
->addAttributeToSelect('is_active');
foreach ($categories as $category)
{
<?php if ($_products = $this->getRecentlyViewedProducts()): ?>
<div class="block block-list block-viewed">
<div class="block-title">
<strong><span><?php echo $this->__('Recently Viewed Products') ?></span></strong>
</div>
<div class="block-content">
<ol id="recently-viewed-items">
<?php foreach ($_products as $_item): ?>
<li class="item">
<p><img class="product-image" src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(50, 50) ?>" width="50" height="50" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" /> </p>
class Getready_Rewrite_Model_Core_Url extends Mage_Core_Model_Url {
/**
* Build url by requested path and parameters
*
* @param string|null $routePath
* @param array|null $routeParams
* @return string
*/
public function getUrl($routePath = null, $routeParams = null) {
@RowanBurgess-zz
RowanBurgess-zz / ScrollToAnchor
Last active August 29, 2015 14:03
Scroll To Anchor
function scrollToAnchor(aid){
var aTag = $j("a[name='"+ aid +"']");
$j('html,body').animate({scrollTop: aTag.offset().top},'slow');
}
#!/bin/sh
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod 550 pear
chmod 550 mage #for magento 1.5+
#In general all files should be 644 and all folders should be 755 and should be owned by the user your web server runs under.
#The mage executable should be given 550 permissions to allow execution.