Skip to content

Instantly share code, notes, and snippets.

View andrewdaluz's full-sized avatar

André andrewdaluz

View GitHub Profile

The magento_targetrule table has action_select and action_select_bind columns with queries that are bad formated with sql commands ad they're not important at all for crossel and upsell products.

Go on vendor/magento/module-target-rule/Model/ResourceModel/Index.php Method protected function _getProductIdsByRule On the method mentioned above you can validate which and what is the bad performatic sql is built. You have the $actionSelect = $rule->getActionSelect(); that is ammended on where() collection query.

To fix that, set null on action_select, action_select_bind columns.

<?php
/*
* Template of virtual host
* {$argv[1]} : nome do projeto
* {$argv[2]} : diretorio do projeto
* @example sudo php create-project-m2.php nome_projeto /var/diretorio/
* created by André Felipe (www.trezo.com.br)
*/
$template = "## Example configuration:\n";
@andrewdaluz
andrewdaluz / section-config.phtml
Created January 12, 2021 16:51
Minicart not updating
When you have multiple path domain like domain.com/storename/, domain.com/storenamexxx/, ...
The mangento misunderstand what is the REQUESTs PATH that it needs update mini cart content.
A quick fix for it we should remove the ending trailing slash from URL UPDATE MAPPING as below:
Create a new rewrite file: app/design/frontend/VENDOR/THEME/Magento_Customer/templates/js/section-config.phtml
<?php
/**
More readable than debug_backtrace():
$e = new \Exception;
var_dump($e->getTraceAsString());
#2 /usr/share/php/PHPUnit/Framework/TestCase.php(626): SeriesHelperTest->setUp()
#3 /usr/share/php/PHPUnit/Framework/TestResult.php(666): PHPUnit_Framework_TestCase->runBare()
namespace Vendor\Module\Helper;
class Data extends \Magento\Framework\App\Helper\AbstractHelper
{
/**
* @var \Magento\Framework\View\LayoutInterface
*/
protected $layout;
@andrewdaluz
andrewdaluz / bootstrap_magento2.md
Last active March 24, 2020 00:08
Bootstrap Magento 2 script
<?php

use Magento\Framework\App\Bootstrap;

require __DIR__ . '/app/bootstrap.php';

$params = $_SERVER;
@andrewdaluz
andrewdaluz / valet-nginx-fix
Last active February 15, 2021 23:04
upstream sent too big header while reading response header from upstream
I was getting this error just now when trying to perform a POST. In my ngnix-error.log I'm seeing this error:
upstream sent too big header while reading response header from upstream
I was able to fix by adding these two lines to my valet.conf file in the location `/usr/local/etc/nginx/valet/valet.conf`:
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

Ansible Playbook complete option

You can simply define the key to use directly when running the command

ansible-playbook \
        \ # Super verbose output incl. SSH-Details:
    -vvvv \
        \ # The Server to target: (Keep the trailing comma!)
 -i "000.000.0.000," \
@andrewdaluz
andrewdaluz / images-multi-store-issue.md
Created February 21, 2019 18:49
Product images error for multi-store

Found the errors

SELECT `cpev_s`.*, `cpev_0`.`value` AS `store_value` FROM `catalog_product_entity_varchar` `cpev_s` JOIN `eav_attribute` `ea` ON `cpev_s`.`attribute_id` = `ea`.`attribute_id` LEFT JOIN `catalog_product_entity_varchar` `cpev_0` ON `cpev_0`.`entity_id` = `cpev_s`.`entity_id` AND `cpev_0`.`attribute_id` = `cpev_s`.`attribute_id` AND `cpev_0`.`store_id` = 0 WHERE `cpev_s`.`value` = 'no_selection' AND `ea`.`attribute_code` IN ('image', 'small_image', 'thumbnail') AND `cpev_s`.`store_id` > 0 AND `cpev_s`.`value` != `cpev_0`.`value` AND `cpev_s`.`value` = 'no_selection';

Delete the entries

DELETE `cpev_s`.* FROM `catalog_product_entity_varchar` `cpev_s` JOIN `eav_attribute` `ea` ON `cpev_s`.`attribute_id` = `ea`.`attribute_id` LEFT JOIN `catalog_product_entity_varchar` `cpev_0` ON `cpev_0`.`entity_id` = `cpev_s`.`entity_id` AND `cpev_0`.`attribute_id` = `cpev_s`.`attribute_id` AND `cpev_0`.`store_id` = 0 WHERE `cpev_s`.`value` = 'no_selection' AND `ea`.`attribute_code` IN ('image'
@andrewdaluz
andrewdaluz / install-composer.md
Last active February 12, 2019 00:05
Install composer
sudo curl -sS https://getcomposer.org/installer | /usr/bin/php
sudo mv composer.phar /usr/bin/composer