Skip to content

Instantly share code, notes, and snippets.

View rodde177's full-sized avatar

rodde177

  • sthlm
View GitHub Profile
@rodde177
rodde177 / gist:431e8c01bed2e66552c5e76e6c5bc3f7
Created July 7, 2016 14:07 — forked from roberto-butti/gist:3509401
Snippet PHP , how to add product in cart and create order in Magento via SOAP API v1
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$config=array();
$config["hostname"] = "my-hostname-with-magento.com";
$config["login"] = "soapuser";
$config["password"] = "soappassword";
$config["customer_as_guest"] = TRUE;
$config["customer_id"] = 261; //only if you don't want as Guest
@rodde177
rodde177 / Release.php
Created August 17, 2016 14:57 — forked from TheFrankman/Release.php
Programatically Create Order
<?php
/**
* @author Frank Clark
*/
namespace Vendor\Namspace\Model\Subscription\Order;
use Vendor\Namspace\Model\ResourceModel\Subscriptions\CollectionFactory;
use Vendor\Namspace\Api\SubscriptionsOrdersRepositoryInterface;
use Vendor\Namspace\Model\SubscriptionsOrdersFactory;
use Vendor\Namspace\Model\Subscriptions;
@rodde177
rodde177 / mailcatcher-install.md
Created September 20, 2016 14:19 — forked from pitpit/mailcatcher-install.md
Install Mailcatcher on OSX
@rodde177
rodde177 / ImageChooser.php
Created October 11, 2016 07:48 — forked from cedricblondeau/ImageChooser.php
Image Chooser for Magento2 widgets
<?php
namespace Vendor\Module\Block\Adminhtml\Widget;
class ImageChooser extends \Magento\Backend\Block\Template
{
/**
* @var \Magento\Framework\Data\Form\Element\Factory
*/
protected $_elementFactory;
<?php
namespace Vendor\Module\Test\Unit;
use Magento\Framework\App\ObjectManagerFactory as AppObjectManagerFactory;
use Magento\Framework\Config\File\ConfigFilePool;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\Driver\File;
use Magento\Framework\App\Filesystem\DirectoryList;
// This is how you would use it. Pass in your collection
// along with an individual callback as well as a batch callback
Mage::getSingleton('stcore/resource_iterator_batched')->walk(
$collection,
array($this, 'batchIndividual'),
array($this, 'batchAfter'),
self::BATCH_SIZE
);
public function batchIndividual($model)
@rodde177
rodde177 / magento quering
Created February 6, 2017 12:03 — forked from srinathweb/magento quering
magento quering
http://fishpig.co.uk/magento/tutorials/direct-sql-queries/
Yes you can run direct sql queries within Magento, the best way to do this is to use the read write resource. You can insatiate it with:
$resource = Mage::getSingleton('core/resource');
$readConnection = $resource->getConnection('core_read');
$writeConnection = $resource->getConnection('core_write');
To run a select you can do something like this:
n98-magerun.phar config:dump | xmlstarlet sel -t -m '/config/global/events/*/observers/*' -v ./class -o ' ' -v ./method -o ' ' -v ./type -n
@rodde177
rodde177 / Observer.php
Created March 17, 2017 01:12 — forked from IvanChepurnyi/Observer.php
Optimized catalog price rules
<?php
class EcomDev_Optimization_Model_Rule_Observer extends Mage_CatalogRule_Model_Observer
{
protected $_preloadedPrices = array();
public function beforeCollectTotals(Varien_Event_Observer $observer)
{
$quote = $observer->getQuote();
$date = Mage::app()->getLocale()->storeTimeStamp($quote->getStoreId());
@rodde177
rodde177 / Magento 2 - tar exclusion parameters.MD
Created April 24, 2017 13:54 — forked from dfelton/Magento 2 - tar exclusion parameters.MD
Magento 2 - Directories to exclude when tarballing a site

Exclusion List

List of exclusion paramters for tar command. Focus put on image cache directories, tmp files, log files, and generated source files.

  • --exclude="./pub/media/*/*/cache"
  • --exclude="./pub/media/js"
  • --exclude="./pub/media/tmp"
  • --exclude="./pub/media/wysiwyg/.thumbs"