Skip to content

Instantly share code, notes, and snippets.

View bradystone's full-sized avatar

bstone bradystone

  • bstone
  • CA
View GitHub Profile
@bradystone
bradystone / 0_reuse_code.js
Created November 21, 2016 20:04
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bradystone
bradystone / Adding-Attributes-to-Product.php
Created January 20, 2017 08:45 — forked from techguysourav/Adding-Attributes-to-Product.php
Magento2 :: Adding Custom Attributes To Products
<?php
namespace Paarth\HelloWorld\Setup;
use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;
class UpgradeData implements UpgradeDataInterface
{
@bradystone
bradystone / host_apache_magento2.conf
Created January 20, 2017 08:51
Virtual Host apache magento2
<VirtualHost *:80>
ServerAdmin info@example.com
DocumentRoot "/Users/example/Sites/magento2"
ServerName local.magento2
<Directory "/Users/example/Sites/magento2">
Options Indexes FollowSymLinks Includes
AllowOverride All
Allow from All
Order deny,allow
</Directory>
@bradystone
bradystone / magento2-deploy.sh
Created January 20, 2017 09:09 — forked from sergiojovanig/magento2-deploy.sh
Deploy Magento 2 steps
php bin/magento setup:backup --db
gzip var/backups/*.sql
git pull
php bin/magento maintenance:enable
php bin/magento cache:enable
rm -fr var/di var/generation var/cache
php bin/magento setup:di:compile
php bin/magento deploy:mode:set production --skip-compilation
php bin/magento maintenance:enable
php bin/magento setup:upgrade
@bradystone
bradystone / Magento2-remove-orders-customers
Created January 20, 2017 09:12 — forked from carlowens/Magento2-remove-orders-customers
Magento 2 remove test data of orders and customers
SET FOREIGN_KEY_CHECKS = 0;
#clear orders
TRUNCATE TABLE `gift_message`;
TRUNCATE TABLE `quote`;
TRUNCATE TABLE `quote_address`;
TRUNCATE TABLE `quote_address_item`;
TRUNCATE TABLE `quote_id_mask`;
TRUNCATE TABLE `quote_item`;
TRUNCATE TABLE `quote_item_option`;
TRUNCATE TABLE `quote_payment`;
setup
-----
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy
php bin/magento setup:di:compile
module
------
php bin/magento module:status
php bin/magento module:enable Kahanit_TableRateShipping
@bradystone
bradystone / M2 acl.xml
Created January 20, 2017 09:13 — forked from Vinai/M2 acl.xml
My current Magento 2 PHPStorm File Templates (Feb 2016)
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
<acl>
<resources>
<resource id="Magento_Backend::admin">
</resource>
</resources>
</acl>
</config>
@bradystone
bradystone / magento2-cookies.MD
Created January 20, 2017 09:14 — forked from mborodov/magento2-cookies.MD
Magento 2 Cookies

Sample work with Cookie in Magento 2

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cookieManager = $objectManager->get('Magento\Framework\Stdlib\CookieManagerInterface');

// set cookie value
$cookieManager->setPublicCookie('key', 'value');

//get cookie value
<?php
use Magento\Framework\App\Bootstrap;
include('app/bootstrap.php');
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
@bradystone
bradystone / magento2_eav_attribute_reference.md
Created January 20, 2017 09:16 — forked from ericrisler/magento2_eav_attribute_reference.md
References related to EAV Attribtues in Magento 2

The array of data you can pass to the \Magento\Eav\Setup\EavSetup::addAttribute() method is as follows:

$data = [
     'group' => 'General', // Name ofgroup in product admin page to place attribtue
     'type' => 'varchar',  // database storeage type (varchar|int|text|decimal)
     'sort_order' => 1000,
     'backend' => '',      // backend_model: class name used to retrieve/save the attribute data to the db
     'frontend' => '',     // frontend_model: ????
     'label' => 'UPC',     // frontend_label: the label text