Skip to content

Instantly share code, notes, and snippets.

View magevision's full-sized avatar

MageVision magevision

View GitHub Profile
@magevision
magevision / checkout_cart_index.xml
Last active October 25, 2017 11:42
Magevision Blog Post #22
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="checkout.cart.shipping">
<action method="setTemplate">
<argument name="template" xsi:type="string">MageVision_Blog22::cart/shipping.phtml</argument>
</action>
<arguments>
<argument name="jsLayout" xsi:type="array">
<item name="components" xsi:type="array">
@magevision
magevision / Data.php
Created October 29, 2017 13:55
Blog Post 23
<?php
namespace MageVision\Blog23\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\Encryption\EncryptorInterface;
class Data extends AbstractHelper
{
const XML_PATH_PASSWORD = 'blog/post23/password';
@magevision
magevision / Index.php
Last active December 4, 2017 15:26
Blog Post 24
<?php
namespace MageVision\Blog24\Controller\Post;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\View\Result\PageFactory;
use Magento\Customer\Model\Session;
class Index extends Action
@magevision
magevision / system.xml
Last active December 28, 2017 12:20
Blog Post 25
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<tab id="magevision" translate="label" sortOrder="1000">
<label>MageVision Blog Posts</label>
</tab>
<section id="blog25" translate="label" type="text" sortOrder="1012" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Blog Post 25</label>
<tab>magevision</tab>
@magevision
magevision / catalog_attributes.xml
Created February 26, 2018 15:18
Add Product Attribute to Quote Item Product
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Catalog:etc/catalog_attributes.xsd">
<group name="quote_item">
<attribute name="manufacturer"/>
</group>
</config>
@magevision
magevision / CustomContent.php
Last active March 7, 2022 12:19
Add Custom Field To CMS Page
<?php
namespace MageVision\Blog15\Block;
class CustomContent extends \Magento\Cms\Block\Page
{
/**
* Prepare HTML content
*
* @return string
*/
@magevision
magevision / form.phtml
Last active February 19, 2022 12:20
Form Validation Custom Error Placement
<form class="form contact"
action="<?php /* @escapeNotVerified */ echo $block->getFormAction(); ?>"
id="contact-form"
method="post"
data-hasrequired="<?php /* @escapeNotVerified */ echo __('* Required Fields') ?>"
data-mage-init='{"validation":{}}'>
<fieldset class="fieldset">
<legend class="legend"><span><?php /* @escapeNotVerified */ echo __('Write Us') ?></span></legend><br />
<div class="field note no-label"><?php /* @escapeNotVerified */ echo __('Jot us a note and we’ll get back to you as quickly as possible.') ?></div>
<div class="field name required">
@magevision
magevision / DefaultConfigProvider.php
Created February 26, 2018 21:26
Get a Product Attribute in Checkout Summary
<?php
namespace MageVision\Blog16\Plugin\Checkout\Model;
use Magento\Checkout\Model\Session as CheckoutSession;
class DefaultConfigProvider
{
/**
* @var CheckoutSession
*/
@magevision
magevision / gender.phtml
Created February 26, 2018 21:38
Display Gender field as Radio button
<div class="field gender<?php if ($block->isRequired()) echo ' required' ?>">
<label class="label" for="<?php /* @escapeNotVerified */ echo $block->getFieldId('gender')?>">
<span><?php /* @escapeNotVerified */ echo __('Gender') ?></span>
</label>
<div class="control">
<?php $options = $block->getGenderOptions(); ?>
<?php $value = $block->getGender(); ?>
<?php foreach ($options as $option): ?>
<?php if(!$option->getValue()) continue; ?>
<div class="field choice">
@magevision
magevision / Image.php
Created February 26, 2018 21:50
Add Image Upload in Configuration
<?php
namespace MageVision\Blog4\Model\Config\Backend;
class Image extends \Magento\Config\Model\Config\Backend\Image
{
/**
* The tail part of directory path for uploading
*/
const UPLOAD_DIR = 'blog/post4';