Skip to content

Instantly share code, notes, and snippets.

@Alexander-Pop
Alexander-Pop / Install Composer to use MAMP's PHP.md
Created July 25, 2023 13:33 — forked from kkirsche/Install Composer to use MAMP's PHP.md
How to install Composer globally using MAMP's PHP

##Create an alias to MAMP's PHP installation

To do this, we can simply create an alias for our bash profile. We'll be doing this is nano, though you can do it in vim or a number of other editors as well.

Within the terminal, run:

nano ~/.bash_profile

This will open nano with the contents, at the top in a blank line add the following line:

@Alexander-Pop
Alexander-Pop / magento-2-dump-and-die-like-laravel.php
Last active July 20, 2023 14:04
Magento 2 debugging method to mimic Laravel dd()
<?php
public function d($arg)
{
if (is_object($arg)) {
echo PHP_EOL . 'CLASS: ' . get_class($arg) . PHP_EOL;
//DB
if ($arg instanceof \Magento\Framework\DB\Select) {
var_dump($arg->__toString());
}
@Alexander-Pop
Alexander-Pop / modal-video.html
Last active December 23, 2022 22:02
[Modal Video] Modal Video #modal #video
<div class="wrapper">
<a class="modal-open" href="#play-video" data-youtube-id="ze_ie8Ctp60">Play Video</a>
</div>
<div class="modal">
<div class="background"></div>
<div class="box">
<div class="close">✖</div>
<h6>Video</h6>
<div class="content">
@Alexander-Pop
Alexander-Pop / footer-on-the-bottom-of-the-page.html
Created September 26, 2022 17:45
Make Footer Stay at Bottom of Page with Bootstrap #html #css #bootstrap #sticky #footer #layout
@Alexander-Pop
Alexander-Pop / generateFibonacciSeries.php
Last active August 4, 2022 10:36
PHP - Generate Fibonacci Series #loop #foreach
<?php
//version 1
function generateFibonacciSeries($input) {
$range = range(0,$input);
$output = [];
foreach($range as $number) {
if($number == 0 || $number == 1) {
array_push($output, $number);
} elseif (array_key_exists($number+1, $range)) {
@Alexander-Pop
Alexander-Pop / AddCustomQuoteOrderItemAttribute.php
Last active June 27, 2022 02:49
Magento 2 - Add Quote / Order Item / custom Customer Attribute (Patch/Schema) #magento2 #quote #order #attribute
<?php
namespace MyNamespace\MyModule\Setup\Patch\Schema;
use Magento\Framework\DB\Ddl\Table;
use Magento\Framework\Setup\Patch\SchemaPatchInterface;
class AddCustomQuoteOrderItemAttribute implements SchemaPatchInterface
{
/**
@Alexander-Pop
Alexander-Pop / ProductCustomer.php
Last active June 27, 2022 02:52
Magento 2 - Filter product / customer using search criteria #magento2 #product #search #customer
<?php
namespace Namespace\MyModule\Block
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\View\Element\Template;
class useCriteria extends Template
@Alexander-Pop
Alexander-Pop / getDirectoryPath.php
Created June 27, 2022 02:03
Magento 2 - get Directory Path #magento2 #routing #action #path #controller
<?php
namespace MyNamespace\MyModule\Controller\Index;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Module\Dir;
class Example extends Action
{
public function __construct(
@Alexander-Pop
Alexander-Pop / AttributeManagement.php
Created June 27, 2022 02:00
Magento 2 - change attribute type to Visual Swatch / Visual Text and add swatch options Ids #magento2 #attribute #interface
<?php
declare(strict_types=1);
namespace MyNamespace\Catalog\Model;
use Dnd\Catalog\Api\AttributeManagementInterface;
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Eav\Api\AttributeRepositoryInterface;
use Magento\Eav\Api\Data\AttributeInterface;
@Alexander-Pop
Alexander-Pop / di.xml
Last active June 27, 2022 02:42
Magento 2 : expose Custom Store Configuration to graphQL #magento2 #graphql
<!-- etc/graphql/di.xml -->
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
<arguments>
<argument name="extendedConfigData" xsi:type="array">
<item name="custom_foo_config" xsi:type="string">mynamespace_mymodule/general/custom_foo_config</item>
</argument>