Skip to content

Instantly share code, notes, and snippets.

Avatar

Jisse Reitsma jissereitsma

View GitHub Profile
@jissereitsma
jissereitsma / fix-memory-report-after-integration-tests.patch
Last active Aug 3, 2020
Fix memory report in certain CI environments, after integration tests have run successfully
View fix-memory-report-after-integration-tests.patch
--- dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php 2020-08-03 11:38:00.536570075 +0200
+++ dev/tests/integration/framework/Magento/TestFramework/Helper/Memory.php 2020-08-03 11:40:49.483161722 +0200
@@ -55,6 +55,7 @@
} catch (\Magento\Framework\Exception\LocalizedException $e) {
// try to use the Windows command line
// some ports of Unix commands on Windows, such as MinGW, have limited capabilities and cannot be used
+ die($e->getMessage());
$result = $this->_getWinProcessMemoryUsage($pid);
}
return $result;
@jissereitsma
jissereitsma / remove-laminas-from-setup-landing-controller.patch
Created Aug 3, 2020
Fix Laminas MVC addition in Magento 2.3.4 file setup/src/Magento/Setup/Controller/Landing.php
View remove-laminas-from-setup-landing-controller.patch
--- setup/src/Magento/Setup/Controller/Landing.php 2020-08-03 10:54:26.952234698 +0200
+++ setup/src/Magento/Setup/Controller/Landing.php 2020-08-03 10:54:35.300358599 +0200
@@ -5,8 +5,8 @@
*/
namespace Magento\Setup\Controller;
-use Laminas\Mvc\Controller\AbstractActionController;
-use Laminas\View\Model\ViewModel;
+use Zend\View\Model\ViewModel;
+use Zend\Mvc\Controller\AbstractActionController;
@jissereitsma
jissereitsma / parse_query_arguments.php
Created Apr 17, 2020
Simple PHP script to destructure query arguments from an URL
View parse_query_arguments.php
<?php
if (!isset($argv) || count($argv) !== 2) {
die('Usage: ' . basename(__FILE__ ). ' {URL}'."\n");
}
$url = $argv[1];
if (empty($url)) {
die("Empty URL");
}
@jissereitsma
jissereitsma / nginx-sample-snippet.conf
Last active Sep 25, 2020
Partial Nginx configuration for Magento 2 with React app in `/public/pwa` folder
View nginx-sample-snippet.conf
#location = / {
# try_files $uri /index.php;
#}
#location / {
# try_files $uri $uri/ /index.php?$args;
#}
location = / {
try_files /pwa/index.html =404;
@jissereitsma
jissereitsma / less_import_parser.php
Created Aug 7, 2018
Script to read a LESS file, resolve its @imports and generate a new LESS file
View less_import_parser.php
<?php
declare(strict_types=1);
class LessImportParser
{
private $content = '';
public function load(string $fileName)
{
$this->content = $this->resolveImports($fileName);
@jissereitsma
jissereitsma / magento_clean_attribute_source_models.php
Created Oct 7, 2017
Magento 1 script to reset attribute models if model can not be instantiated (because module is uninstalled)
View magento_clean_attribute_source_models.php
<?php
require_once 'app/Mage.php';
Mage::app();
$autoFix = true;
class Clean_Attribute_Source_Models
{
private $autofix;
private $modelFields = ['backend_model', 'frontend_model', 'source_model'];
@jissereitsma
jissereitsma / dutchento-meetup-data.php
Created Jul 15, 2017
Dutchento meetup data of all Magento User Groups
View dutchento-meetup-data.php
<?php
include_once 'vendor/autoload.php';
use DMS\Service\Meetup\MeetupKeyAuthClient;
$apiKey = 'enter-your-own-meetup-api-key';
$client = MeetupKeyAuthClient::factory(array('key' => $apiKey));
$meetupGroupUrlNames = array(
'Magento-User-Group-Friesland',
View m2_truncate_catalog.sql
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `cataloginventory_stock_item`;
TRUNCATE TABLE `cataloginventory_stock_status`;
TRUNCATE TABLE `cataloginventory_stock_status_idx`;
TRUNCATE TABLE `cataloginventory_stock_status_tmp`;
TRUNCATE TABLE `catalog_category_product`;
TRUNCATE TABLE `catalog_category_product_index`;
TRUNCATE TABLE `catalog_category_product_index_tmp`;
View create_image_demo.php
<?php
/*
* - Switch to composer package
* - Namespacing
* - Use file/handler package
* - Use downloader package
* - Use image creation package
*/
interface ImageGenerator
View facebooksignup.php
<?php
require_once 'app/Mage.php';
Mage::app();
$collection = Mage::getModel('facebooksignup/facebooksignup')
->getCollection()
->addFieldToFilter('customer_id',$user_id)
->limit(1); //////line 19 is here
foreach ($collection as $data) {