Skip to content

Instantly share code, notes, and snippets.

@6ui11em
6ui11em / magento2_query_product_no_image.sql
Created October 3, 2023 17:05
Magento 2: Query products without image
SELECT * FROM `catalog_product_entity` WHERE `entity_id` NOT IN (SELECT `entity_id` FROM `catalog_product_entity_media_gallery_value_to_entity`) AND `entity_id` IN (SELECT entity_id FROM `catalog_product_entity_int` WHERE attribute_id = ( SELECT attribute_id FROM `eav_attribute` WHERE `attribute_code` = 'status' ) AND `catalog_product_entity_int`.value = 1)
@6ui11em
6ui11em / creative-cloud-disable.md
Created December 27, 2022 08:52 — forked from andreibosco/creative-cloud-disable.md
disable creative cloud startup on mac
@6ui11em
6ui11em / magento2-apply-combine-conditions.php
Last active May 19, 2022 11:01
Magento 2: Aplicar conditions al collection #mageno2
<?php
use Magento\Rule\Model\Condition\Sql\Builder as SqlBuilder;
...
/** @var $collection Collection */
$collection = $this->productCollectionFactory->create();
$conditions = $this->getConditions();
$productConditions = $this->getProductConditions();
$conditions->collectValidatedAttributes($collection);
@6ui11em
6ui11em / Magento 2 - Remove all customer data
Created December 14, 2021 14:26 — forked from rafaelstz/Magento 2 - Remove all customer data
Remove all Magento 2 test Sample Data
SET FOREIGN_KEY_CHECKS=0;
TRUNCATE TABLE `customer_entity`;
TRUNCATE TABLE `customer_entity_datetime`;
TRUNCATE TABLE `customer_entity_decimal`;
TRUNCATE TABLE `customer_entity_int`;
TRUNCATE TABLE `customer_entity_text`;
TRUNCATE TABLE `customer_entity_varchar`;
TRUNCATE TABLE `customer_address_entity`;
TRUNCATE TABLE `customer_address_entity_datetime`;
@6ui11em
6ui11em / csp_whitelist.xml
Created June 18, 2021 14:33
Magento 2: Content Security Policy XML #magento2 #content-security #whitelist #csp
<?xml version="1.0" encoding="UTF-8"?>
<!--
The HTTP Content-Security-Policy response header allow you to control what pages to load for specific
user agents.
This mostly involves defining rules for specific origins or script endpoints, and helps guard against
cross-site scripting attacks (XSS).
-->
<csp_whitelist
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@6ui11em
6ui11em / recirect.txt
Created June 1, 2021 06:10
.htaccess: Redirect all to index.html #htaccess #redirect
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
@6ui11em
6ui11em / addProductVideo.php
Created May 13, 2021 00:15
Magento 2: Add Youtube Video to product #video #magento2 #youtube
<?php
/* Source: https://mage2.pro/t/topic/1741/11 */
namespace Yourcompany\Yourmodule\Controller\Test;
use Magento\Framework\Api\Data\VideoContentInterface;
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
use Magento\Framework\App\Action\Context;
use Magento\ProductVideo\Model\Product\Attribute\Media\ExternalVideoEntryConverter;
use Magento\Store\Model\Store;
use Magento\Framework\Exception\InputException;
@6ui11em
6ui11em / youtube-api.php
Created May 13, 2021 00:12
Youtube: Get Video Information API call PHP #youtube #php #api #video
$api_key = "API Key"
$video_id = "Video ID"
$url = "https://www.googleapis.com/youtube/v3/videos?id=" . $video_id . "&key=" . $api_key . "&part=snippet,contentDetails,statistics,status";
$json = file_get_contents($url);
$getData = json_decode( $json , true);
foreach((array)$getData['items'] as $key => $gDat){
$title = $gDat['snippet']['title'];
}
// Output title
echo $title;
@6ui11em
6ui11em / youtube-id.php
Created May 13, 2021 00:11
Regexp: Get Youtube ID from Url #regexp #youtube
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@6ui11em
6ui11em / route.xml
Created May 5, 2021 08:19
Magento 2: Route #magento2 #route
<?xml version="1.0"?>
<!--
Credits: https://mdotacademy.snippets.cc/collection/magento-2/create-route
Place this file in either the "frontend" or "adminhtml" folder to define either
a frontend or admin route, respectively:
ex. app/code/Foo/Bar/etc/frontend/routes.xml
The "urn:magento:framework:App/etc/routes.xsd" file is used to validate this
XML file. You can inspect it at vendor/magento/framework/App/etc/routes.xsd