use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
/**
* @var CategoryCollectionFactory
*/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Remove the last link in breadcrumbs | |
| // WHY? Because it an span tag that contains the title of the page | |
| // But you're already on the page, so what's the point? | |
| add_filter( 'wpseo_breadcrumb_links', 'jj_wpseo_breadcrumb_links' ); | |
| function jj_wpseo_breadcrumb_links( $links ) { | |
| //pk_print( sizeof($links) ); | |
| if( sizeof($links) > 1 ){ | |
| array_pop($links); |
The goal of this script is to help you migrate you old Magento Luma code to Hyvä compliant code. Luma used to rely on Require.js to manage it's javascript components. Hyvä relies on Alpine.js for this. For a lot of modules there are already compatibility modules available. Custom code you have to convert yourself.
There are several ways to use this code:
- Using Tampermonkey (Chrome) or Greasemonkey (Firefox). If you have that installed just click on "Raw" by the
requirejs-finder.user.jsfile. - (Temporary) By injecting it into Magento's head. Open the admin and navigate to Content -> Design -> Click your theme -> HTML -> Head -> Add `` and place the code above between the two script tags.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| echo "🎉 👏 Congrats with the new project! 🎉 👏 | |
| I'm setting up your fresh WordPress install for you." | |
| # Make new folder | |
| printf "Enter folder name of your choice -> " | |
| read FOLDER | |
| mkdir $FOLDER | |
| cd $FOLDER |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="video-section"> | |
| <h2>{{ section.settings.heading }}</h2> | |
| {%- if section.settings.video_url.type == 'youtube' -%} | |
| <iframe src="https://www.youtube.com/embed/{{ section.settings.video_url.id }}" class="youtube" allow="autoplay; encrypted-media" title="{{ section.settings.description | escape }}"></iframe> | |
| {%- else -%} | |
| <iframe src="https://player.vimeo.com/video/{{ section.settings.video_url.id }}" class="vimeo" allow="autoplay; encrypted-media" title="{{ section.settings.description | escape }}"></iframe> | |
| {%- endif -%} | |
| </div> | |
| {% schema %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Run with the URL pointing to a require-config.js as the first argument; | |
| // php identify.php http://magento2demo.firebearstudio.com/pub/static/frontend/Magento/luma/en_US/requirejs-config.js | |
| $content = file_get_contents($argv[1]); | |
| preg_match_all( | |
| '/(?P<quote>\'|")(?P<extension>[[:alnum:]]+_[[:alnum:]]+)\/js\/.+?(?P=quote)/m', | |
| $content, | |
| $matches |
Snippets frequently used with Sage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use in conjunction with https://gist.github.com/woogists/c0a86397015b88f4ca722782a724ff6c | |
| <a class="cart-customlocation" href="<?php echo wc_get_cart_url(); ?>" title="<?php _e( 'View your shopping cart' ); ?>"><?php echo sprintf ( _n( '%d item', '%d items', WC()->cart->get_cart_contents_count() ), WC()->cart->get_cart_contents_count() ); ?> - <?php echo WC()->cart->get_cart_total(); ?></a> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Show cart contents / total Ajax | |
| */ | |
| add_filter( 'woocommerce_add_to_cart_fragments', 'woocommerce_header_add_to_cart_fragment' ); | |
| function woocommerce_header_add_to_cart_fragment( $fragments ) { | |
| global $woocommerce; | |
| ob_start(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public $email; | |
| public function updated($name) | |
| { | |
| $this->validateOnly($name, [ | |
| 'email' => 'required|email', | |
| ]); | |
| } |
NewerOlder