Skip to content

Instantly share code, notes, and snippets.

@manojiksula
manojiksula / MyCustomBlock.php
Created April 23, 2020 12:03 — forked from crittermike/MyCustomBlock.php
Drupal 8 block with custom cache context and tags
<?php
class MyCustomBlock extends BlockBase {
public function build() {
return array(
'#markup' => $this->t('My custom block content'),
'#cache' => array(
'contexts' => ['url.path'], // https://www.drupal.org/developing/api/8/cache/contexts
'tags' => ['node:1', 'node:2'] // https://www.drupal.org/developing/api/8/cache/tags
),

Get All Products

Only the sku and name parameters for product items whose category_gear attribute includes the value 86 are returned by the following query.

GET <host>/rest/<store_code>/V1/products/?searchCriteria[filter_groups][0][filters][0][field]=category_gear
&searchCriteria[filter_groups][0][filters][0][value]=86&searchCriteria[filter_groups][0][filters][0][condition_type]=finset
&fields=items[sku,name]
@manojiksula
manojiksula / gist:90ac770ba4bf16be8db492963af10885
Created April 16, 2020 07:14
Sublime Text 3 license key 2020 Updated and working perfectly
Thanks GUys use this oone
----- BEGIN LICENSE -----
Member J2TeaM
Single User License
EA7E-1011316
D7DA350E 1B8B0760 972F8B60 F3E64036
B9B4E234 F356F38F 0AD1E3B7 0E9C5FAD
FA0A2ABE 25F65BD8 D51458E5 3923CE80
87428428 79079A01 AA69F319 A1AF29A4
@manojiksula
manojiksula / container-layout-names.md
Created April 14, 2020 10:53 — forked from joshfortyfour/container-layout-names.md
List of container layout names in Magento 2 Community Edition
  • actions_apply_to
  • admin.scope.col.wrap
  • adminhtml.block.report.product.lowstock.grid.container
  • adminhtml.catalog.product.set.edit.wrapper
  • after.body.start
  • alert.urls
  • assign_products_container
  • available_sort_by_group
  • backend.page
  • backend.session.activity
@manojiksula
manojiksula / Magento2-API-OAuth-based_authentication.php
Created April 12, 2020 18:55 — forked from rafaelstz/Magento2-API-OAuth-based_authentication.php
Sample files to use Magento 2 REST and SOAP API. Using Token-based authentication and OAuth-based authentication method.
<?php
function sign($method, $url, $data, $consumerSecret, $tokenSecret)
{
$url = urlEncodeAsZend($url);
$data = urlEncodeAsZend(http_build_query($data, '', '&'));
$data = implode('&', [$method, $url, $data]);
$secret = implode('&', [$consumerSecret, $tokenSecret]);
```php
<?php
// error_reporting(E_ALL);
// ini_set('display_errors', 1);
// // // require('vendor/zendframework/zend-server/src/Client.php');
// // // require('vendor/zendframework/zend-soap/src/Client.php');
// // // require('vendor/zendframework/zend-soap/src/Client/Common.php');
// // $wsdlurl = 'http://127.0.0.1/m2/soap/all?wsdl_list=1';
Fatal error: Uncaught ReflectionException: Class Magento\Framework\App\ResourceConnection\Proxy does not exist in 
/var/www/html/vendor/magento/framework/Code/Reader/ClassReader.php:26 
Stack trace: #0 /var/www/html/vendor/magento/framework/Code/Reader/ClassReader.php(26): 
ReflectionClass->__construct('Magento\\Framewo...') 
#1 /var/www/html/vendor/magento/framework/ObjectManager/Definition/Runtime.php
(54): Magento\Framework\Code\Reader\ClassReader->getConstructor('Magento\\Framewo...') 
#2 /var/www/html/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php(48):
Magento\Framework\ObjectManager\Definition\Runtime->getParameters('Magento\\Framewo...') 
#3 /var/www/html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): 
@manojiksula
manojiksula / gist:01e39538797e6b03c69049a069f99ede
Created February 5, 2020 16:46 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@manojiksula
manojiksula / FancyService.php
Created January 2, 2020 14:16 — forked from Jaesin/FancyService.php
Autowiring services in Drupal 8
<?php
/**
* @file `src/FancyService.php`
*
* Fancy service provides lyric segments from Iggy Azalea's song, "Fancy".
*/
namespace Drupal\example;
use Drupal\Core\Language\LanguageManagerInterface;

Using cache in Drupal 8

$cid = 'token_key:' . \Drupal::languageManager()->getCurrentLanguage()->getId();

// get details from cache \Drupal::cache()->get($unique_key)

if ($cache = \Drupal::cache()->get($cid)) { 
    $data = $cache->data;
}
else {