Skip to content

Instantly share code, notes, and snippets.

@timbroder
timbroder / gist:1293491
Created October 17, 2011 19:13
Creating a Stateless Request in Magento 2
<?php
class Ai_AjaxCatalog_Controller_Action extends Mage_Core_Controller_Front_Action
{
public function preDispatch()
{
$this->setFlag('', self::FLAG_NO_START_SESSION, 1); // Do not start standard session
parent::preDispatch();
return $this;
}
}
@timbroder
timbroder / gist:1293475
Created October 17, 2011 19:06
Creating a Stateless Request in Magento 1
<?php
...
if (!$this->getFlag('', self::FLAG_NO_START_SESSION)) {
$checkCookie = in_array($this->getRequest()->getActionName(), $this->_cookieCheckActions);
$checkCookie = $checkCookie && !$this->getRequest()->getParam('nocookie', false);
$cookies = Mage::getSingleton('core/cookie')->get();
if ($checkCookie && empty($cookies)) {
$this->setFlag('', self::FLAG_NO_COOKIES_REDIRECT, true);
}
Mage::getSingleton('core/session', array('name' => $this->_sessionNamespace))->start();
@timbroder
timbroder / wtf7.js
Created October 6, 2011 20:15
wtf7
$j.each(item.parent().parent().parent().next().children('.inner').children().children('.row').children('.details'),function(){
var qty = $j(this).children().children('.kit_qty').html();
$j(this).children().children('.kit_qty').html(json.itemsQty);
var price = $j(this).children().children('.total').children().children('.price').html();
totalSave = totalSave+((price.substr(1,price.length)/qty)*json.itemsQty);
$j(this).children().children('.total').children().children('.price').html("$"+(price.substr(1,price.length)/qty)*json.itemsQty);
});
@timbroder
timbroder / delete wordpress posts by category
Created October 4, 2011 13:36
delete wordpress posts by category
SELECT p.post_title, p.ID, wpr.object_id, wp_terms.term_id, wp_terms.name, wp_term_taxonomy.taxonomy
FROM wp_terms
INNER JOIN wp_term_taxonomy ON wp_terms.term_id = wp_term_taxonomy.term_id
INNER JOIN wp_term_relationships wpr ON wpr.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id
INNER JOIN wp_posts p ON p.ID = wpr.object_id
WHERE taxonomy = 'category'
AND p.post_type = 'post'
AND p.post_status = 'publish'
AND name != 'Code'
ORDER BY object_id;
@timbroder
timbroder / hg mercurial branching
Created September 29, 2011 19:11
hg mercurial branching
hg pull
hg update
hg update default
hg merge UAT.RC12
hg commit -m "merged UAT.RC12 into default"
hg update UAT.RC12
hg commit --close-branch -m "closing branch UAT.RC12"
hg branch UAT.RC13
hg commit -m "created branch UAT.RC13"
hg push --new-branch
@timbroder
timbroder / gist:1250743
Created September 29, 2011 13:41
endeca tunnel
ssh -L10008:8.14.113.146:10008 [email protected]
ssh -L8888 :8.14.113.146:8888 [email protected]
Then I override the hardcoded "8.14.113.146" in lib/Ai_Endeca/Endeca_SOAP.class.php with "localhost"
You can setup a similar tunnel on 8888 if you want to use the test implimentation, then you could go here:
http://localhost:8888/endeca_jspref/controller.jsp?sid=1302CF39EB83&enePort=10008&Ne=1000&eneHost=localhost&N=0
@timbroder
timbroder / Rakefile
Created September 29, 2011 02:05 — forked from stammy/Rakefile
Goes in Rakefile for Jekyll for those wanting tag pages
# Using multi-word tags support from http://tesoriere.com/2010/08/25/automatically-generated-tags-and-tag-clouds-with-jekyll--multiple-word-tags-allowed-/
# If using with jekyll gem, remove bits loop and site.read_bits('') and add require 'rubygems' and require 'jekyll'
# Using full HTML instead of layout include to manually set different page title (tag, not tag_slug) and canonical URL in header
desc 'Build tags pages'
task :build_with_tags do
sh 'rm -rf _site'
puts "Generating tags..."
<?php
/**
* Magento Enterprise Edition
*
* NOTICE OF LICENSE
*
* This source file is subject to the Magento Enterprise Edition License
* that is bundled with this package in the file LICENSE_EE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.magentocommerce.com/license/enterprise-edition
@timbroder
timbroder / gist:1209944
Created September 11, 2011 18:32
insert update url rewrite
#INSERT INTO `core_url_rewrite` (`store_id`, `category_id`, `product_id`, `id_path`, `request_path`, `target_path`, `is_system`)
SELECT 1 AS `store_id`,
`sub`.`category_id`,
`sub`.`entity_id` AS `product_id`,
CONCAT('product', '/', `entity_id`, '/', `category_id`) AS `id_path`,
`value` AS `request_path`,
CONCAT('catalog/product/view/id/', `entity_id`, '/category/', `category_id`) AS `target_path`,
1 AS `is_system`
FROM
(SELECT
if($_product->getAdrIsRefurbished() == 1) { ?>
<li><a href="#" class="lb_waystosave"
rel="refurbished_products"><?php echo $refurbished['count']?>
Refurbished <?php if($pricecount==0){if($refurbished['count']>1) { echo 'from ';}else{ echo 'for ';}?>
<?php echo Mage::helper('core')->currency($pricepointdata['adr_is_refurbished']['lowest_price'],true,false);$pricecount=1;}?>
</a></li>
<?php }