Skip to content

Instantly share code, notes, and snippets.

View razbakov's full-sized avatar
🖖
Hi

Aleksey Razbakov razbakov

🖖
Hi
View GitHub Profile
@razbakov
razbakov / ProductList.php
Created January 26, 2012 14:55
ProductList in layered navigation
<?php
//...
public function setCollection($collection){
//...
$collection->joinAttribute('hohlkammern', 'catalog_product/hohlkammern', 'entity_id', null, 'right');
$collection->joinAttribute('hohlkammern_alt', 'catalog_product/hohlkammern_alt', 'entity_id', null, 'right');
$collection->joinAttribute('ausreissteg', 'catalog_product/ausreissteg', 'entity_id', null, 'right');
$whereStatement = "
at_hohlkammern.value = {$hohlkammern}
@razbakov
razbakov / translator.html
Created January 23, 2012 15:48
Bing Translator
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script>
function translate_bing(text, sl, tl, success, complete){
if(typeof(complete) != 'function')
complete = function(){};
jQuery.ajax({
url: 'http://api.bing.net/json.aspx?JsonCallback=?',
dataType: 'jsonp',
data: {
'AppId' : 'F3A5B8832ED2798D80A77717B631E18229AD3A84',
@razbakov
razbakov / social.html
Created December 21, 2011 10:04
Social
<div id="bookmarklets">
<div class="social-block"><a rel="nofollow" href="//verify.authorize.net/anetseal/?pid=9c8826fe-f014-42c5-93c6-a0ca8b5da24f&amp;rurl=http%3A//www.biggestdiamond.com/" target="_blank"> <img src="{{skin url="images/foot-04.png"}}" alt="" /> </a></div>
<div class="social-block">
<div class="fb-like" data-send="false" data-layout="box_count" data-width="60" data-show-faces="true"></div>
</div>
<div class="social-block">
<div class="g-plusone" data-size="tall" data-count="true"></div>
</div>
</div>
@razbakov
razbakov / template.php
Created December 9, 2011 17:27
Templates
<?php
class SomeClass {
public function somefunction()
{
$orderId = 1; // some order id for example
$order->load($orderId);
$vars['order_id'] = $order->getIncrementId();
$vars['order_date'] = $order->getCreatedAt();
$vars['order_day'] = date('d', strtotime($order->getCreatedAt()));
@razbakov
razbakov / shipment.php
Created December 7, 2011 14:46
Shipment
<?php
/** @var $order Mage_Sales_Model_Order */
$order = Mage::getModel('sales/order');
$order->load($orderId);
/** @var $shipment Mage_Sales_Model_Order_Shipment */
$shipment = Mage::getModel('sales/order_shipment');
$shipment->setOrder($order);
@razbakov
razbakov / observer.php
Created December 2, 2011 13:58
Order Code
<?php
$order = new Mage_Sales_Model_Order();
$incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$order->loadByIncrementId($incrementId);
/** @var $order Mage_Sales_Model_Order */
$cookieModel = Mage::getModel('core/cookie');
// Save order ad origin as order field
@razbakov
razbakov / math.md
Created November 9, 2011 14:25
6:2*(1+2)=?

"I am your college professor that you requested, with a doctorate in Mathematics. I will break this down as simply as possible and end this debate as approx. 10 students have already asked me this today. The problem as it is written is 6÷2(1+2) , the ÷ cannot be substituted with a fraction bar because they have different ranks on the order of operations. It is an illegal math move to do this. The bar ranks with parentheses, ÷ is interchangeable with . therefore the problem must be solved as 6÷2(1+2) NOT 6 (over) 2(1+2) we do the parentheses first, so 6÷2(3), the parentheses are now no longer relevant, because the number inside is in it's simplest form. Every single number has implied parentheses around it. 6÷2(3) (6) ÷(2)(3) 6÷23, or even converting the division to multiplication by a reciprocal (a legal math move) (6)(1 (over) 2)(3) are all correct ways to write this problem and mean exactly the same thing. Using pemdas, where md and as are interchangeable, we work from left to right, so (3)(3) or 3*

@razbakov
razbakov / home_page_banner.html
Created November 7, 2011 14:34
Home page banner slides
<div id="slider">
<div class="showcase-slide"><img src="http://flavs.dev/media/catalog/category/resized/orig_sample_05_5_480x480.jpg" alt="" /></div>
<div class="showcase-slide"><img src="http://flavs.dev/media/catalog/category/resized/orig_sample_05_5_480x480.jpg" alt="" /></div>
<div class="showcase-slide"><img src="http://flavs.dev/media/catalog/category/resized/orig_sample_05_5_480x480.jpg" alt="" /></div>
<div class="showcase-slide"><img src="http://flavs.dev/media/catalog/category/resized/orig_sample_05_5_480x480.jpg" alt="" /></div>
</div>
@razbakov
razbakov / verif.js
Created November 3, 2011 14:10
Example jquery.validate.min.js
$(document).ready(function(){
$("#contactForm").submit(function(){
return $("#contactForm").validate();
})
});
@razbakov
razbakov / functions.php
Created November 2, 2011 15:22
Добавляем список похожих записей в своем блоге
<?php
function related_posts_shortcode( $atts ) {
extract(shortcode_atts(array(
'limit' => '5',
), $atts));
global $wpdb, $post, $table_prefix;
if ($post->ID) {