Skip to content

Instantly share code, notes, and snippets.

View markshust's full-sized avatar
🤓
Working on educational & training material for Magento 2

Mark Shust markshust

🤓
Working on educational & training material for Magento 2
View GitHub Profile
@markshust
markshust / mysql_myisam_to_innodb.php
Created February 25, 2014 17:08
PHP script to convert MySQL tables from MyISAM to InnoDB
<?php
$conn = mysql_connect('server', 'username', 'password');
mysql_select_db('database', $conn);
$sql = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE engine <> 'InnoDB'";
$rs = mysql_query($sql);
while ($row = mysql_fetch_array($rs)) {
$tbl = $row[0];
$sql = "ALTER TABLE $tbl ENGINE=INNODB";
@markshust
markshust / printescp.js
Last active August 29, 2015 13:57
printESCP testing
function printESCP() {
if (notReady()) { return; }
qz.append('\x1B' + '\x40'); // init
qz.append('\x1B' + '\x61' + '\x31'); // center align
qz.append('Hello world!' + '\x0A');
qz.append('\x0A'); // line break
qz.append('\x1B' + '\x61' + '\x30'); // left align
qz.append('This is a test...' + '\x0A');
qz.append('\x0A');
@markshust
markshust / Estimate.php
Last active August 29, 2015 13:57
OnePica AvaTax - fix for hash key serialization error in app/code/community/OnePica/AvaTax/Model/Avatax/Estimate.php
/**
* Generates a hash key for the exact request
*
* @return string
*/
protected function _genRequestKey() {
$request = @(string)(array)$this->_request;
$hash = sprintf("%u", crc32(serialize($request)));
Mage::getSingleton('avatax/session')->setLastRequestKey($hash);
return $hash;
<?php
/**
* Set global/skip_process_modules_updates to '1' in app/etc/local.xml and
* then use this script to apply updates and refresh the config cache without
* causing a stampede on the config cache.
*
* @author Colin Mollenhour
*/
umask(0);
ini_set('memory_limit','512M');
@markshust
markshust / gist:c8a05ac66128353a4808
Created August 2, 2014 12:05
Magento 1.7.0.0 Dataflow Profile for Importing Product Images
<action type="dataflow/convert_parser_csv" method="parse">
<var name="delimiter"><![CDATA[,]]></var>
<var name="enclose"><![CDATA[]]></var>
<var name="fieldnames"></var>
<var name="map">
<map name="sku"><![CDATA[sku]]></map>
<map name="image"><![CDATA[image]]></map>
<map name="image_label"><![CDATA[image_label]]></map>
<map name="small_image"><![CDATA[small_image]]></map>
<map name="small_image_label"><![CDATA[small_image_label]]></map>
/* Responsive styles created by Valentin Niklasson */
@media screen and (min-width : 954px) {
div.checkoutcontainer div.input-city { width: 45%!important; }
div.checkoutcontainer div.input-country select { width: 83%!important; }
div.checkoutcontainer div.input-city { width: 100%!important; }
div.checkoutcontainer div.input-region { width: 55.8%!important; }
div.checkoutcontainer div.input-address-short .input-text,
div.checkoutcontainer div.input-firstname .input-text,
div.checkoutcontainer div.input-lastname .input-text,
div.checkoutcontainer div.input-email .input-text,
@markshust
markshust / gist:765f6f6145d2b48f556c
Created August 11, 2014 16:50
setup firebase token generator for php
# get composer
curl -sS https://getcomposer.org/installer | php
# download required php-jwt library
php composer.phar require firebase/php-jwt
# get php-jwt and required Authentication dir
git clone git@github.com:firebase/php-jwt.git
ln -s php-jwt/Authentication Authentication
@markshust
markshust / createCookie.js
Last active August 29, 2015 14:11
Create a cookie with JavaScript
/**
* Creates a cookie
*
* If expiresVal is null, only create session cookie
* ExpiresType is either y, d, h, or m (years, days, minutes or hours)
*
* @param name
* @param value
* @param expiresVal
* @param expiresType
@markshust
markshust / app.routes.js
Last active August 29, 2015 14:11
Check Firebase auth token expiry with AngularJS
function Run($cookies, $firebaseAuth, $rootScope, $state, FBURL) {
var authRef = new Firebase(FBURL),
clock = parseInt(getServerTime(authRef) / 1000),
expires = 0;
$rootScope.auth = $firebaseAuth(authRef);
$rootScope.logout = function() {
$rootScope.auth.$logout();
$rootScope.checkSession();
@markshust
markshust / gist:9b7de35cb5291073d59d
Created January 16, 2015 21:55
Fatal error: Call to a member function toOptionArray() on a non-object in magento
diff --git a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
index 09fe084..b834f11 100644
--- a/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
+++ b/app/code/core/Mage/Adminhtml/Block/System/Config/Form.php
@@ -460,7 +460,11 @@ class Mage_Adminhtml_Block_System_Config_Form extends Mage_Adminhtml_Block_Widge
}
}
} else {
- $optionArray = $sourceModel->toOptionArray($fieldType == 'multiselect');
+ if (is_object($sourceModel)) {