how tho change number of posts in loop from specific categories

I anm trying to get my home loop query filled like this:

  1. From all posts within all categories: show (just) 1 (most recent) post.
  2. From some specific caegories: show 3 (most recent) posts (max).
  3. Sort on publish date.
    website: www.baiweb.nl

The combination 1,3 and 2,3 is pretty standard, but I can’t figure out how to script the two combined.

Appriciate to get some help!

php – Data/profile export categories name instead of Ids (magento 1.9)

I have done this script to runs data/profile using ssh terminal to export csv data of all products inside of magento 1.9.
I need to have the category name (structure tree) instead of category Ids but i do not know how to do that.
Attached my code.

<?php
#$profileId = 1; #All Products
$profileId = 49; #OnSale
require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$profile = Mage::getModel('dataflow/profile');
$userModel = Mage::getModel('admin/user');
$userModel->setUserId(0);
Mage::getSingleton('admin/session')->setUser($userModel);
$profile->load($profileId);
if (!$profile->getId()) {
 Mage::getSingleton('adminhtml/session')->addError('(ERROR) Invalid ID');
}
Mage::register('current_convert_profile', $profile);
$profile->run();
$recordCount = 0;
?>

woocommerce – Hide children categories from a plugin / shortcode

My theme comes with an addon plugin that include some visual constructor element.

They display the products on my homepage, with categories filter. But I want to exclude subcategories products (children).

I already tried to add “include_children => false” in what I suppose to be the query, but it has no incidence on the code.

Here is the code of the bloc :

function supro_products( $atts, $content ) {

    $atts = shortcode_atts(

        array(

            'title'            => '',

            'subtitle'         => '',

            'style'            => '1',

            'limit'            => 6,

            'columns'          => 3,

            'm_columns'        => 1,

            'orderby'          => 'title',

            'order'            => 'ASC',

            'filter'           => 'category',

            'show_all_product' => '1',

            'all_product_text' => esc_html__( 'All Products', 'supro' ),

            'tabs'             => '',

            'category'         => '',

            'link'             => '',

            'load_more'        => false,

            'btn_style'        => 'border-bottom',

            'css_animation'    => '',

            'el_class'         => '',

        ), $atts

    );



    if ( ! $this->wc_actived ) {

        return;

    }



    $css_class = array(

        'supro-products-grid supro-products',

        'style-' . $atts('style'),

        $atts('btn_style'),

        $this->get_css_animation( $atts('css_animation') ),

        'mobile-columns-' . $atts('m_columns'),

        $atts('el_class')

    );



    if ( $atts('load_more') ) {

        $css_class() = 'load-more-enabled';

    }



    $output = array();

    $title  = '';

    $filter = array();

    $type   = 'products';

    $attr   = array();



    $product_args = array(

        'limit'     => $atts('limit'),

        'columns'   => $atts('columns'),

        'page'      => 1,

        'orderby'   => $atts('orderby'),

        'order'     => $atts('order'),

        'category'  => '',

        'load_more' => $atts('load_more'),

    );



    $tabs = vc_param_group_parse_atts( $atts('tabs') );



    if ( $atts('title') ) {

        $title = sprintf( '<h3 class="title">%s</h3>', $atts('title') );

    }



    if ( $atts('subtitle') ) {

        $title .= sprintf( '<div class="subtitle">%s</div>', $atts('subtitle') );

    }



    if ( $title ) {

        $title = '<div class="section-title">' . $title . '</div>';

    }



    if ( $atts('filter') == 'category' ) {

        $attr = array(

            'limit'   => intval( $atts('limit') ),

            'columns' => intval( $atts('columns') ),

            'orderby' => $atts('orderby'),

            'order'   => $atts('order'),

        );



        if ( intval( $atts('show_all_product') ) ) {

            $filter() = sprintf(

                '<li class="active" data-filter="%s">%s</li>',

                $atts('category') ? $atts('category') : '',

                $atts('all_product_text')

            );

        } else {

            if ( $atts('category') ) {

                $cats                     = explode( ',', $atts('category') );

                $product_args('category') = $cats(0);



            } else {

                $terms                    = get_terms( 'product_cat' );

                $empty_terms              = array();

                $new_terms                = array_merge( $terms, $empty_terms );

                $product_args('category') = $new_terms(0)->slug;

            }

        }



        if ( $atts('category') ) {

            $cats = explode( ',', $atts('category') );



            foreach ( $cats as $cat ) {

                $cat      = get_term_by( 'slug', $cat, 'product_cat' );

                $filter() = sprintf( '<li class="" data-filter="%s">%s</li>', esc_attr( $cat->slug ), esc_html( $cat->name ) );

            }

        } else {

            $terms = get_terms( 'product_cat' );



            foreach ( $terms as $term ) {

                $filter() = sprintf( '<li class="" data-filter="%s">%s</li>', esc_attr( $term->slug ), esc_html( $term->name ) );

            }

        }



    } else {

        $product_args('category') = $atts('category');

        $css_class()              = 'filter-by-group';



        if ( $tabs ) {

            $type = $tabs(0)('products');



            $i = 0;

            foreach ( $tabs as $tab ) {

                $tab_attr = array(

                    'limit'   => intval( $atts('limit') ),

                    'columns' => intval( $atts('columns') ),

                    'orderby' => isset( $tab('orderby') ) ? $tab('orderby') : $atts('orderby'),

                    'order'   => isset( $tab('order') ) ? $tab('order') : $atts('order'),

                );

                if ( isset( $tab('title') ) ) {

                    $filter() = sprintf( '<li class="" data-filter="%s" data-attr="%s">%s</li>', esc_attr( $tab('products') ), esc_attr( json_encode( $tab_attr ) ), esc_html( $tab('title') ) );

                }



                if ( $i == 0 ) {

                    $atts('orderby') = isset( $tab('orderby') ) ? $tab('orderby') : $atts('orderby');

                    $atts('order')   = isset( $tab('order') ) ? $tab('order') : $atts('order');

                }



                $i ++;

            }

        }

    }



    $link = '';



    if ( $atts('link') && $atts('style') == '3' ) {

        $link = '<div class="product-btn">' . $this->get_vc_link( $atts, '' ) . '</div>';

    }



    $filter_html = '<ul class="nav-filter filter">' . implode( "n", $filter ) . '</ul>';



    $output() = $atts('style') == '3' ? $title : '';

    $output() = '<div class="product-header">';

    $output() = $atts('style') != '3' ? $title : '';

    $output() = $filter_html;

    $output() = $link;

    $output() = '</div>';

    $output() = '<div class="product-wrapper">';

    $output() = '<div class="product-loading"><span class="supro-loader"></span></div>';

    $output() = $this->get_wc_products( $product_args, $type );

    $output() = '</div>';



    return sprintf(

        '<div class="%s" data-attr="%s" data-load_more="%s" data-nonce="%s">%s</div>',

        esc_attr( implode( ' ', $css_class ) ),

        esc_attr( json_encode( $attr ) ),

        esc_attr( $atts('load_more') ),

        esc_attr( wp_create_nonce( 'supro_get_products' ) ),

        implode( '', $output )

    );

}

My two questions are :

  • how to hide all subcategory products
  • is it possible to make it thru functions.php ? Or should I overwrite the plugin Code ? Can I for example duplicate this bloc, with a new name in my child theme directly ?

category – Can I get whole categories (Item Types) as search results from my website’s search bar?

Many visitors of my website search for categories instead of certain items on the search bar. However the store is not configured to show this type of results. What would be the way to define a number of keywords that when searched, will lead to a result page with all the products of a certain category? Thanks in advance!

product – Error while exporting categories in magento 1.9

i am using extension http://magentoworks.net/importexport-magento-category-extension/ to export categories but stuck in following error. anybody know how to fix it .

Fatal error: Uncaught Error: Function name must be a string in /home2/fillcraf/public_html/app/code/local/Mageworks/Export/Block/Adminhtml/Export.php:143 Stack trace: #0 /home2/fillcraf/public_html/app/code/local/Mageworks/Export/Block/Adminhtml/Category/Export/Categories.php(36): Mageworks_Export_Block_Adminhtml_Export->saveCsvContent(Array, Object(Mage_Catalog_Model_Category)) #1 /home2/fillcraf/public_html/app/code/core/Mage/Core/Block/Abstract.php(923): Mageworks_Export_Block_Adminhtml_Category_Export_Categories->_toHtml() #2 /home2/fillcraf/public_html/app/code/local/Mageworks/Export/controllers/Adminhtml/ExportController.php(16): Mage_Core_Block_Abstract->toHtml() #3 /home2/fillcraf/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mageworks_Export_Adminhtml_ExportController->categoryAction() #4 /home2/fillcraf/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('category') #5 /home2/fillcraf/public_html/app/code/core/Mage/ in /home2/fillcraf/public_html/app/code/local/Mageworks/Export/Block/Adminhtml/Export.php on line 143

rest api – Magento API call return all categories details and sub categories details

I’m currently working on an application that requires the display of categories and was able to get the category image via this endpoint:
http://example.com/rest/V1/categories/12 where 12 is the category id.

It returns:

{
    "id": 12,
    "parent_id": 11,
    "name": "Tops",
    "is_active": true,
    "position": 1,
    "level": 3,
    "children": "14,15,16,17",
    "created_at": "2020-10-26 13:04:12",
    "updated_at": "2020-11-09 15:31:03",
    "path": "1/2/11/12",
    "available_sort_by": [],
    "include_in_menu": true,
    "custom_attributes": [
        {
            "attribute_code": "image",
            "value": "/pub/media/catalog/category/31uKiYhGcSL._AC_.jpg"
        },
        {
            "attribute_code": "display_mode",
            "value": "PRODUCTS"
        },
        {
            "attribute_code": "is_anchor",
            "value": "1"
        },
        {
            "attribute_code": "path",
            "value": "1/2/11/12"
        },
        {
            "attribute_code": "children_count",
            "value": "4"
        },
        {
            "attribute_code": "custom_use_parent_settings",
            "value": "0"
        },
        {
            "attribute_code": "custom_apply_to_products",
            "value": "0"
        },
        {
            "attribute_code": "url_key",
            "value": "tops-men"
        },
        {
            "attribute_code": "url_path",
            "value": "men/tops-men"
        }
    ]
}

But the problem is it doesn’t return the subcategories of that category, to get the subcategories, I need to go to http://example.com/mag24/rest/V1/categories?depth=1&rootCategoryId=12

Which returns:

{
    "id": 12,
    "parent_id": 11,
    "name": "Tops",
    "is_active": true,
    "position": 1,
    "level": 3,
    "product_count": 678,
    "children_data": [
        {
            "id": 14,
            "parent_id": 12,
            "name": "Jackets",
            "is_active": true,
            "position": 1,
            "level": 4,
            "product_count": 176,
            "children_data": []
        },
        {
            "id": 15,
            "parent_id": 12,
            "name": "Hoodies & Sweatshirts",
            "is_active": true,
            "position": 2,
            "level": 4,
            "product_count": 208,
            "children_data": []
        },
        {
            "id": 16,
            "parent_id": 12,
            "name": "Tees",
            "is_active": true,
            "position": 3,
            "level": 4,
            "product_count": 192,
            "children_data": []
        },
        {
            "id": 17,
            "parent_id": 12,
            "name": "Tanks",
            "is_active": true,
            "position": 4,
            "level": 4,
            "product_count": 102,
            "children_data": []
        }
    ]
}

One solution would be to get all the subcategories and then loop through each of them to get the details, but I’m looking for a simpler and efficient approach if possible?

ct.category theory – Are fibered categories fibrant objects in some model structure on Cat/C?

Given a category $mathcal{C}$, by a category over $mathcal{C}$, I mean a category $mathcal{D}$ along with a functor $pi_{mathcal{D}}:mathcal{D}rightarrow mathcal{C}$.

Consider the category $Cat/C$, of categories over $mathcal{C}$. I am assuming the familiarity with the notion of a fibered category over $mathcal{C}$ (if not, please see Definition 3.5 of Angelo Vistoli’s Notes on Grothendieck topologies,fibered categoriesand descent theory).

Question is the following:

  • Is there a (interesting/non-trivial) model structure on $Cat/mathcal{C}$, in which fibered categories are fibrant objects?

Or, are the terms “fibered category” and “fibrations” just two unrelated terms that sound same?

category products – Magento 2.4 Elastic Search Categories Emptying

I have recently updated to Magento 2.4 and on my test site it works perfectly fine.

However, on my production site my categories randomly empty. To fix it, I manually run the bin/magento index:reindex and everything is back to normal.

I did initially have memory issues with the server where the memory would run out and the Elastic Search service would crash. I have since doubled memory and the service is no longer crashing, but I am still seeing issues with categories emptying.

I cannot see anything in the logs that indicates what the issue is.

I have also tried all indexes on ‘Update on Save’ and ‘Update on Schedule’. When set on ‘Update on Save’ categories don’t seem to empty as much.

Has anyone come across this?

My current Elastic Search health is yellow, and I have read I to get it to green I need to add an additional node, which I am hoping may resolve the issue.