Skip to content

Instantly share code, notes, and snippets.

@mrmoyeez
mrmoyeez / export_categories.php
Created December 3, 2019 11:48 — forked from bluec/export_categories.php
Export Magento category tree with full names, paths and URLs
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
@mrmoyeez
mrmoyeez / sort-by-discount.php
Created December 9, 2019 06:53 — forked from EricBusch/sort-by-discount.php
Add "Sort by discount" to sorting options. Defaults to biggest to smallest discount.
<?php
/**
* Add "Sort by discount" to sorting options. Defaults to biggest to smallest discount.
*/
add_filter( 'woocommerce_get_catalog_ordering_args', 'mycode_woocommerce_add_salediscount_to_catalog_ordering_args' );
function mycode_woocommerce_add_salediscount_to_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'discount' == $orderby_value ) {
$args['orderby'] = 'meta_value_num';
<?php
namespace Company\Module\Block\Product\ProductList;
class Toolbar extends \Magento\Catalog\Block\Product\ProductList\Toolbar
{
public function setCollection($collection) {
$this->_collection = $collection;
$this->_collection->setCurPage($this->getCurrentPage());
@mrmoyeez
mrmoyeez / plugins.php
Created September 14, 2021 07:06 — forked from anonymous/plugins.php
Add extra info to WooCommerce product
<?php
/**
* Plugin Name: Pharmacy
* Plugin URI: http://domain.com
* Description: Add extra info for pharmacy products
* Author: Your name
* Author URI: http:// domain.com
* Version: 1.0
*/
<?php
/**
*
* You can find the complete tutorial for this here:
* https://pluginrepublic.com/woocommerce-custom-fields
*
* Alternatively, check out the plugin
* https://pluginrepublic.com/wordpress-plugins/woocommerce-product-add-ons-ultimate/
*