Skip to content

Instantly share code, notes, and snippets.

View molotovbliss's full-sized avatar
⚗️
Code, Eat, Sleep++;

Jared molotovbliss

⚗️
Code, Eat, Sleep++;
  • DFW, Texas
View GitHub Profile
@molotovbliss
molotovbliss / gist:cb2e3fc92684307d7e5b
Created September 11, 2014 20:08
Memory limit proof generate CSV of missing product images
<?php
// generate a CSV of id,sku of products with missing images to var/missingimages.csv
// core/resource_iterator used to prevent memory max limits issues
// original source: https://stackoverflow.com/questions/3565377/how-can-i-find-all-products-without-images-in-magento
require_once('app/Mage.php');
umask(0);
ini_set('display_errors', 1);
Mage::setIsDeveloperMode(true);
<!--[if !IE]><!-->
<style>
/*
/*
Generic Styling, for Desktops/Laptops
*/
table {
width: 100%;
border-collapse: collapse;
@molotovbliss
molotovbliss / tools.php
Created September 16, 2014 20:12
shell/tools.php Shell Development Template
<?php
/*
* General shell template used in development
*/
require_once 'abstract.php';
// Generic PHP development settings
umask(0);
@molotovbliss
molotovbliss / gist:4d2ff3de4c56197fc106
Created October 9, 2014 21:15
SQL Update all products with missing weight
UPDATE catalog_product_entity_decimal SET value = '1' WHERE attribute_id = 80 AND value IS NULL
@molotovbliss
molotovbliss / explode.function.sql
Created October 20, 2014 16:40
SQL Function: PHP explode similar
/**
* Split a string by string (Similar to the php function explode())
*
* @param VARCHAR(12) delim The boundary string (delimiter).
* @param VARCHAR(255) str The input string.
* @param INT pos The index of the string to return
* @return VARCHAR(255) The (pos)th substring
* @return VARCHAR(255) Returns the [pos]th string created by splitting the str parameter on boundaries formed by the delimiter.
* @{@example
* SELECT SPLIT_STRING('|', 'one|two|three|four', 1);
@molotovbliss
molotovbliss / gist:6c22ff02b50ccce3a643
Created February 17, 2015 07:43
sitemap.xml to .txt list of urls one liner, used with siege
php -r '$x=new SimpleXMLElement(file_get_contents("sitemap.xml"));foreach($x->url as $n) echo $n->loc.PHP_EOL;' > urls.txt
@molotovbliss
molotovbliss / gist:120dbb07903f3bf08c9f
Created February 17, 2015 11:31
Poor mans oneliner debug
echo __FILE__ .":". __LINE__ . PHP_EOL . __METHOD__;
@molotovbliss
molotovbliss / gist:605a0de924197895bc74
Last active August 29, 2015 14:15
addMediaGalleryAttributeToCollection
// Source: http://www.magentocommerce.com/boards/viewthread/17414/#t141830
function addMediaGalleryAttributeToCollection(Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection $_productCollection) {
$_mediaGalleryAttributeId = Mage::getSingleton('eav/config')->getAttribute('catalog_product', 'media_gallery')->getAttributeId();
$_read = Mage::getSingleton('core/resource')->getConnection('catalog_read');
$_mediaGalleryData = $_read->fetchAll('
SELECT
main.entity_id, `main`.`value_id`, `main`.`value` AS `file`,
`value`.`label`, `value`.`position`, `value`.`disabled`, `default_value`.`label` AS `label_default`,
@molotovbliss
molotovbliss / gist:3c7352f774873fb737c3
Last active February 22, 2021 12:28
Using cURL via CLI to debug Magento's XML-RPC API calls
If any exceptions are encountered due to 3rd party/local observers debugging can be questionable as no log
is created to determine root cause. This mini doc covers how to use the XML-RPC API in Magento to test a
product update API call that is returning a 500 internal server error due to an observer firing in 3rd party
code. Using some simple XML docs prepared for login and the request it is easier to see the Fatal error
returned for a request, in this example product.update.
xmlrpclogin.xml contents:
<?xml version="1.0"?>
<methodCall>
@molotovbliss
molotovbliss / Flat.php
Last active August 29, 2015 14:18
Get attributes via Flat table instead of EAV
<?php
/*
* Get attributes via Flat table instead of EAV alternative to the resource heavy
* $product->getTypeInstance()->getConfigurableAttributesAsArray()
* Source: http://www.atwix.com/magento/custom-resource-model-magento-product-flat-tables/
*/
class Company_Custom_Model_Resource_Flat extends Mage_Core_Model_Resource_Db_Abstract
{
protected $_storeId;