Skip to content

Instantly share code, notes, and snippets.

@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 / 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
<?php
class DataTransformer
{
public function transform(): \Generator
{
while ($request = yield) {
yield $request . ' - appended';
}
}
@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';
/**