Skip to content

Instantly share code, notes, and snippets.

View krillo's full-sized avatar
😼
Happy

Kristian Erendi krillo

😼
Happy
View GitHub Profile
@krillo
krillo / all configurable productss, get lowest price from related, update configurable prod. All store views
Created April 21, 2017 14:02
Get all configurable prods, loop their simple prods and find the lowest price and update the configurable prod with it. Do it for all store views
@krillo
krillo / Magento 1: Generate campaign codes
Created April 20, 2017 12:06
Magento 1: Generate campaign codes
/**
* Generate campaign codes
* @param type $cuponRuleId
* @param type $nbr
* @param type $prefix
* @param type $suffix optional
* @return type
*/
public function generateCampaignCode($cuponRuleId, $nbr, $prefix, $suffix = '') {
$rule = Mage::getModel('salesrule/rule')->load($cuponRuleId); // Get the rule in question
@krillo
krillo / jQuery: find min height of elements
Last active April 13, 2017 13:48
jQuery: find min height of elements
<script type="text/javascript">
jQuery(document).ready(function ($) {
var minHeight = 0;
$('.macro-env-images li img').each(function (index) {
height = $(this).height();
console.log(index + ": " + $(this).height());
if (index === 0) {
minHeight = height;
}
if (height > 0 && height < minHeight) {
@krillo
krillo / Magento1: loop through configurable prods children
Created April 11, 2017 14:04
Loop through configurable prods children and get a custom attribute articlegroup
<?php
//loop through configurable prods children and get a custom attribute articlegroup
$_product = $this->getProduct();
$productType = $_product->getTypeID();
$articleGroup = '';
if ($productType == 'configurable') {
$childProducts = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($_product->getID());
foreach ($childProducts[0] as $childId => $value) {
$child = Mage::getModel('catalog/product')->load($childId);
$articleGroup = $child->getArticlegroup();
@krillo
krillo / Magento1: All active categories, save to csv-file
Created April 10, 2017 14:19
Magento1: All active categories, save to csv-file
<?php
/**
* allActiveCategories.php
*
* Gets all active catgories and writes them to a file "categories.csv"
* Put this in your magento 1 webroot and run from your browser
* krillo
*/
require __DIR__ . '/app/Mage.php';
Mage::app(Mage_Core_Model_App::ADMIN_STORE_ID)->setUseSessionInUrl(false);
<?php
$this->startSetup();
$this->addAttribute('catalog_category', 'inkclub', array(
'group' => 'General Information',
"type" => "int",
"backend" => "",
"frontend" => "",
"label" => "Inkclub",
"input" => "select",
"class" => "",