Skip to content

Instantly share code, notes, and snippets.

View dpdexter's full-sized avatar

David Dexter dpdexter

View GitHub Profile
@dpdexter
dpdexter / gist:1271562
Created October 7, 2011 23:11
Getting BrilliantRetail Category Images
{exp:query sql="SELECT * FROM exp_br_category WHERE parent_id = (SELECT category_id FROM exp_br_category WHERE url_title = 'products') ORDER BY sort"}
<h2>{title}</h2>
{url_title}
<br />
{image}
<br />
{detail}
<hr />
{/exp:query}
@dpdexter
dpdexter / gist:1303003
Created October 21, 2011 03:01
BR price_html error [#0000125]
function _check_product_price($p)
{
$group_id = $this->EE->session->userdata["group_id"];
// Deal with our price matrix
foreach($p["price_matrix"] as $price){
if( $price["group_id"] == 0 ||
$price["group_id"] == $group_id){
$amt = array(
@dpdexter
dpdexter / gist:1337437
Created November 3, 2011 18:55
Bash Rename Files
for i in REG_* ; do mv $i `echo $i | sed 's/REG_//'`; done
@dpdexter
dpdexter / gist:1340855
Created November 5, 2011 00:21
Promo validation returns false positive on disabled promotions
function _validate_promo_code($code){
if($code["enabled"] == 0){ return false; }
if($code["uses_per"] > 0){
$cnt = $this->EE->promo_model->get_promo_use_count($code["code"]);
if($cnt >= $code["uses_per"]){
return false;
}
}
@dpdexter
dpdexter / gist:1432288
Created December 5, 2011 04:24
_search_index
function _search_index($queryStr){
// Need at least 3 characters for wildcard searches
if(strlen($queryStr) >= 3){
// Dashes don't play nicely with our wildcard search
$queryStr = str_replace("-"," ",$queryStr).'*';
}
ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.PATH_THIRD.'brilliant_retail'.DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.PATH_SEPARATOR);
include_once(PATH_THIRD.'brilliant_retail'.DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'library'.DIRECTORY_SEPARATOR.'Zend'.DIRECTORY_SEPARATOR.'Search'.DIRECTORY_SEPARATOR.'Lucene.php');
Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_TextNum_CaseInsensitive());
@dpdexter
dpdexter / gist:3228636
Created August 1, 2012 16:44
BrilliantRetail + Structure Patch
UPDATE exp_extensions SET priority = 99 WHERE class = 'Brilliant_retail_ext' AND method = 'br_template_post_parse';
@dpdexter
dpdexter / gist:4207649
Created December 4, 2012 19:14
BrilliantRetail - Change product display price when options are selected.
{exp:brilliant_retail:js}
var price,newPrice,qty,opt,adj;
$(function(){
price = parseInt($('p.price').html().replace('$',''))*1;
$('select','.product-options')
.change(function(){
qty = $('option:selected','#qty_select').val();
newPrice = price;
{exp:query sql="
SELECT
title as category_title,
url_title as category_url_title,
image as category_image,
FROM exp_br_category,
WHERE parent_id = 0
ORDER BY sort
"}
@dpdexter
dpdexter / gist:5154156
Created March 13, 2013 17:09
Remove .DS_Store
find . -name *.DS_Store -type f -exec rm {} \;
@dpdexter
dpdexter / gist:6602456
Created September 17, 2013 23:55
BR 1.3.4.3 (dev release) patch for free shipping bug
function _producttype_multiselect($product_id,$attribute_id,$title,$label,$required,$val,$opts = ''){
$class = ($required == 1) ? 'required' : '' ;
$input_title = ($required == 1) ? $label.' '.lang('br_is_required') : $label ;
$options = '';
##### BEGIN PATCH: ADD THIS BELOW THE OPTIONS VARIABLE ######
// Check to make sure the value is not serialized
$data = @unserialize($val);