Skip to content

Instantly share code, notes, and snippets.

View denvit's full-sized avatar
🎯
Focusing

Denis Veg denvit

🎯
Focusing
  • Gornja Radgona, Slovenia
  • 11:46 (UTC +02:00)
View GitHub Profile
@denvit
denvit / algoliaexport.rb
Last active June 30, 2023 18:20
Ruby script to get a list of records in Algolia index
# 1. Install ruby using brew
# 3. Run in terminal: gem install algoliasearch
# 4. Run this script in terminal: ruby script.rb
require 'json'
require 'algoliasearch'
Algolia.init(application_id: '<insert id here>', api_key: '<insert admin key here>')
index = Algolia::Index.new('< name of your index >')
@denvit
denvit / csp_whitelist.xml
Created May 13, 2022 12:00
Magento_CSP xml file
<?xml version="1.0"?>
<!--
/**
* Copyright Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<csp_whitelist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Csp/etc/csp_whitelist.xsd">
<policies>
<policy id="default-src">
@denvit
denvit / gist:5c4688ddbaeeb77bcb785702349b03f9
Created July 21, 2021 13:15
Script for generating SSL certificate on MacOSX
#!/bin/bash
echo Enter domain:
read domain
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
@denvit
denvit / sphp.sh
Created November 27, 2020 14:20 — forked from w00fz/sphp.sh
PHP switcher
#!/bin/bash
# Check if command was ran as root.
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
echo "When a service requires root access, you will be prompted for a password as needed."
exit 1
fi
# Usage
@denvit
denvit / magento2_move_files.php
Last active May 28, 2024 10:17
Magento 2 - move file
<?php
\Magento\Framework\Filesystem\Io\File $file
\Magento\Framework\App\Filesystem\DirectoryList $directoryList
/**
* @param array $files
* @throws \Magento\Framework\Exception\FileSystemException
*/
public function archiveFile(array $files)
@denvit
denvit / CheckIfOrdersSent.php
Last active May 28, 2024 10:22
It checks through the 3rd party API (ITscope) if distributor already sent ordered products to the customer.
<?php
namespace Vendor\Distributors\Jobs;
use DateTime;
use DateTimeZone;
use Vendor\Distributors\Helpers\DistributorData;
use Exception;
use GuzzleHttp\Exception\GuzzleException;
use Magento\Framework\Api\SearchCriteriaBuilder;
@denvit
denvit / catalog_product_view.xml
Last active May 27, 2020 06:28
Add custom block on product details page
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
...
<referenceBlock name="product.info.social">
<block class="Magento\Catalog\Block\Product\View" name="product.info.brand" as="brand" template="Magento_Catalog::product/view/brand.phtml"></block>
</referenceBlock>
...
</body>
</page>
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// For performance use one level down: 'name/{,*/}*.js'
// If you want to recursively match all subfolders, use: 'name/**/*.js'
module.exports = function (grunt) {
'use strict';
@denvit
denvit / FileSaver.js example
Created December 15, 2019 18:20
Save content to file using javascript
<script src="http://cdn.jsdelivr.net/g/filesaver.js"></script>
<script>
function SaveAsFile(t,f,m) {
try {
var b = new Blob([t],{type:m});
saveAs(b, f);
} catch (e) {
window.open("data:"+m+"," + encodeURIComponent(t), '_blank','');
}
}
@denvit
denvit / Firebear\ConfigurableProducts\Plugin\Pricing\Price\FinalPrice.php
Created November 8, 2019 11:49
Solution for Firebear Configurable products NoSuchEntityException on categories
public function afterGetValue(\Magento\ConfigurableProduct\Pricing\Price\FinalPrice $subject, $result)
{
/**
* @todo Add check on whether preselect is enabled
**/
$defaultProductId = $this->defaults->getDefaultProductId($subject->getProduct());
if (!$defaultProductId) {
$defaultProductId = (int) $this->_request->getParam('id');
}
if ($defaultProductId) {