Skip to content

Instantly share code, notes, and snippets.

@gplanchat
gplanchat / php_unserialize_to_json.sql
Last active July 28, 2022 10:01 — forked from damoclark/php_unserialize_to_json.sql
PHP unserialize in Postgresql to json
/**
Decode a php serialized value to json. This function only supports basic
data types:
- arrays (will always become a json object)
- booleans
- integers
- floats
- strings
- NULL
@gplanchat
gplanchat / ImportProductsCommand.php
Last active June 16, 2021 14:31 — forked from nicanaca0/ImportProductsCommand.php
Simple CSV Product importer for Sylius. Includes the product, the variant, channel pricing, taxons images and associations (1.0.0-beta.2)
<?php
namespace AppBundle\Command;
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Product\Model\ProductAssociationInterface;
use Sylius\Component\Product\Model\ProductAssociationTypeInterface;
use Sylius\Component\Taxonomy\Model\TaxonInterface;
@gplanchat
gplanchat / Makefile
Created December 19, 2018 10:28
Get the best performances from your Magento 2.x
.PHONY: webperf
webperf:
rm -rf *
<?php
class DataTransformer
{
public function transform(): \Generator
{
while ($request = yield) {
yield $request . ' - appended';
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Title</title>
<link rel="stylesheet" href="bower_components/material-design-lite/material.css" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
### Keybase proof
I hereby claim:
* I am gplanchat on github.
* I am gplanchat (https://keybase.io/gplanchat) on keybase.
* I have a public key whose fingerprint is 8009 DB5C EC65 87FC E5F8 AFA6 C7AF 5AE0 49C8 2C1D
To claim this, I am signing this object:
@gplanchat
gplanchat / SortableTrait.php
Last active January 26, 2016 17:42 — forked from real34/SortableTrait.php
Allow to implement sorting in a Magento frontend Block easily.
<?php
trait Foo_Catalog_Block_List_SortableTrait
{
/**
* @var string
*/
protected $_orderVarName = 'order';
/**
<?php
function factory($path, ...$args) {
$callback = require $path . '.php';
if (!$callback instanceof Closure) {
return $callback;
}
return $callback(...$args);
}
@gplanchat
gplanchat / Abstract.php
Created June 5, 2015 14:10
PHP 5.5 patch for Magento 1.9
<?php
class Mage_Core_Helper_Abstract
{
//...
/**
* Remove html tags, but leave "<" and ">" signs
*
* @param string $html
* @return string
*/
diff --git a/web/app/code/core/Mage/Core/Model/Config.php b/web/app/code/core/Mage/Core/Model/Config.php
index bc68381..2e7c009 100644
--- a/web/app/code/core/Mage/Core/Model/Config.php
+++ b/web/app/code/core/Mage/Core/Model/Config.php
@@ -843,12 +843,7 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base
foreach ($modules as $moduleName => $moduleProps) {
$depends = $moduleProps['depends'];
foreach ($moduleProps['depends'] as $depend => $true) {
- if (!$moduleProps['active']) {
- $depends = [];