Woocommerce categories disable

I want to disable the ability for someone to pick a category when he uploads a product .
Hint : I want only to disable the option to pick a… | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1839253&goto=newpost

uicomponent – Custom Category Attribute not rendered in backend Categories Page

i try to add a new category attribute in Magento 2.3.6 and render an input in the category backend.
Setup worked, attribute is created. But the category_form.xml seems to be ignored. Maybe someone can show me whats wrong here.

I used this explanation first:
https://devdocs.magento.com/guides/v2.3/ui_comp_guide/howto/add_category_attribute.html

But i dont get the Attribute shown in backend. Module is enabled, setup creates the entries in eav_attribute and catalog_eav_attribute. I dont have errors in the logs.

Vendor/Module/Setup/InstallData.php

<?php
namespace VendorModuleSetup;

use MagentoFrameworkSetup{
    ModuleContextInterface,
    ModuleDataSetupInterface,
    InstallDataInterface
};

use MagentoEavSetupEavSetup;
use MagentoEavSetupEavSetupFactory;

class InstallData implements InstallDataInterface
{
    private $eavSetupFactory;
    
    public function __construct(EavSetupFactory $eavSetupFactory) {
        $this->eavSetupFactory = $eavSetupFactory;
    }
    
    public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $eavSetup = $this->eavSetupFactory->create(('setup' => $setup));
        $eavSetup->removeAttribute(MagentoCatalogModelCategory::ENTITY, 'product_group');
        $eavSetup->addAttribute(MagentoCatalogModelCategory::ENTITY, 'product_group', (
            'type'     => 'varchar',
            'label'    => 'Product Group',
            'default'  => null,
            'input'    => 'text',
            'visible'  => true,
            'required' => false,
            'global'   => MagentoEavModelEntityAttributeScopedAttributeInterface::SCOPE_STORE,
            'group'    => 'general',
            'source' => '',
            'backend'  => '',
            'user_defined' => false,
            'sort_order'   => 100,
        ));
    }
}

UI Component
Vendor/Module/view/adminhtml/ui_component/category_form.xml

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="general">
        <field name="product_group">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="required" xsi:type="boolean">false</item>
                    <item name="validation" xsi:type="array">
                        <item name="required-entry" xsi:type="boolean">false</item>
                    </item>
                    <item name="sortOrder" xsi:type="number">100</item>
                    <item name="dataType" xsi:type="string">string</item>
                    <item name="formElement" xsi:type="string">input</item>
                    <item name="label" translate="true" xsi:type="string">Product Group</item>
                </item>
            </argument>
        </field>
    </fieldset>
</form>

Would be great if someone can help me 🙂

Regards,
Andreas

react.js – Data state filter on toggle by categories

Here is a simple react app that will list some dummy data and can be filtered by categories (in this case, by user ID) by toggling the button on/off.

FilterBtn.js

import React, { useContext, useState } from "react";
import DataContext from "../../context/dataContext";
import "./FilterBtn.css";

const FilterBtn = ({ category }) => {
  const { currentCategory, setCategory, filterData } = useContext(DataContext);

  const (isFilter, setIsFilter) = useState(false);

  /* The idea here is to toggle the filter by click and then send both category
     and isFilter in order to trigger the filter dispatch in State
  */

  const onClick = () => {

    /* Not sure on how to properly make this work since setIsFilter is asynchronous
       and isFilter will still be false. I read that useEffect or useCallback could work
       but I am not sure if they are efficient at all.
    */
    // setIsFilter(prevState => !prevState) also doesn't seem to work.

    setIsFilter(!isFilter);

    /* This is to set the currentCategory in order to know which button is being clicked on
       and will apply the highlighted class on it if true
    */

    if (currentCategory !== category) {
      setCategory(category);
    } else {
      setCategory(null);
    }

    // Here I invert isFilter so that it will be sent to state as "true"
    filterData(category, !isFilter);

    /* Note that the toggle logic is still flawed, and will not toggle the data as expected if the
       toggle switch constantly between buttons
    */
  };

  return (
    // I need to know which category it is currently being toggled on in order to change the class
    <button
      value={category}
      onClick={onClick}
      className={currentCategory === category ? "highlighted" : ""}
    >
      User {category}
    </button>
  );
};

export default FilterBtn;

DataState.js

import React, { useReducer } from "react";
import DataContext from "./dataContext";
import DataReducer from "./dataReducer";
import axios from "axios";
import types from "./types";

const { GET_DATA, FILTER_DATA, SET_CATEGORY } = types;

const DataState = ({ children }) => {
  const initialState = {
    data: (),
    currentCategory: null
  };

  const (state, dispatch) = useReducer(DataReducer, initialState);

  // To set the currentCategory being clicked on

  const setCategory = (category) => {
    dispatch({
      type: SET_CATEGORY,
      payload: category
    });
  };

  // The filter works by sending category parameter to the backend in order to filter the data and then send it back again to react
  // There is probably a way to filter without having to fire another request to backend

  const filterData = async (userId, filter) => {
    // Some simple logic in which filter will only trigger if category exists and filter is true

    if (userId && filter) {
      const res = await axios.get(
        `https://jsonplaceholder.typicode.com/posts?userId=${userId}`
      );

      dispatch({
        type: FILTER_DATA,
        payload: res.data
      });
    } else {
      // Get the localStorage data, which stores the initial unfiltered data

      const savedData = JSON.parse(localStorage.getItem("data"));

      dispatch({
        type: GET_DATA,
        payload: savedData
      });
    }
  };

  const fetchData = async () => {
    const res = await axios.get("https://jsonplaceholder.typicode.com/posts");

    // Save the unfiltered data in localStorage in order to be able to get them again if filter is false

    localStorage.setItem("data", JSON.stringify(res.data));

    dispatch({
      type: GET_DATA,
      payload: res.data
    });
  };

  return (
    <DataContext.Provider
      value={{
        data: state.data,
        fetchData,
        setCategory,
        filterData,
        currentCategory: state.currentCategory
      }}
    >
      {children}
    </DataContext.Provider>
  );
};

export default DataState;

DataReducer.js

import types from "./types";
const { GET_DATA, FILTER_DATA, SET_CATEGORY } = types;

export default (state, action) => {
  switch (action.type) {
    case GET_DATA:
      return {
        ...state,
        data: action.payload
      };

    case FILTER_DATA:
      return {
        ...state,
        data: action.payload
      };

    case SET_CATEGORY:
      return {
        ...state,
        currentCategory: action.payload
      };
    default:
      return state;
  }
};

I leveraged localStorage in order to implement this feature (save initial unfiltered data in localStorage during fetch, and get the data from localStorage when the toggle is off).
This code just feels like it can be improved.

Here is the working codesandbox:
https://codesandbox.io/s/agitated-butterfly-xbm1n

plugins – Is there is any way to add validation for sub categories in backend while publishing posts

My requirement is while submitting posts, If I selected a parent category that has a child category, I need to add validation, I need to select only child category if it has a parent category. For those categories which don’t have child categories, we can select parent categories.

Is there is any way to add validation for this

covid 19 – Categories passenger locator form essential travel via Belgium

The Belgian Essential Travel sworn statement has a number of categories, but I’m not sure which one I should pick.

Specifically, I am an EU resident with primary residence in another EU country (not Belgium). I’m considering transiting in Belgium on my return from an essential trip outside the EU.

My entire trip (assuming I choose Belgium as my entry point back to the EU) looks as follows:

EU country of residence =flight=> non-EU country where my physical presence is required (this is the main reason for my entire trip) =flight=> Brussels (entry-point back to the EU) =car=> EU country of residence

The Belgian Passenger Locator Form has a number of essential travel categories which may seem relevant, but it mostly depends on whether I choose the category for my entire trip (as described above) or the trip back home (i.e. starting at the the non-EU country where my physical presence is required).

If it is the former, I could choose the option ‘a trip in the context of a legal obligation, insofar as it is necessary and cannot be done online’ and bring along supporting documents showing that my physical presence is required at my destination. Of course that won’t support the need for my trip back home.

If choosing the latter, I would simply argue that I am travelling home and that such a trip is essential per se. Two options in the form seem to support that reason:

  • a transit trip;
  • for an individual whose primary residence is abroad: departure from Belgium after a trip which commenced before 27 January 2021.

The last reason is phrased a bit ambiguously, I’m not sure if this applies only to those who are already in Belgium (so that this reason only supports travel departing Belgium) or if it also applies to arrivals who plan to leave immediately (the trip, regardless of how it is defined starts after January 27th).

The transit reason seems the most straightforward if my assumption that travelling home is always essential.

TL;DR:
Do the essential travel categories on the Belgian passenger locator form refer to the trip as a whole or to the (narrowest) part of the trip that involves travel through Belgium?

categories – Can I add arguments to a woocommerce block – to show more products or paginator

I’m trying to have a page/post show all products in a specified category.
I want to use a simple method if possible. I have the theme “NewEStore Pro” to use…

There are now separate pages/posts corresponding to each/every category… in each I place a block (comment: and after that block have a custom shortcode from stackexch link if youre interrested).

The block:

<!-- wp:woocommerce/product-category {"categories":(29)} /-->

I get to see 9 products…

So, can I add an argument to this block to allow viewing all products in the category?

My thoughts are, either an argument like “count_limit”:100 … or “pagination”:true

I would be grateful for an answer. Greetings

ct.category theory – Self-enrichments of rigid monoidal categories

A closed monoidal category $mathcal{C}$ is a one for which the functor $X otimes -$ admits a right adjoint, for every $X in mathcal{C}$. As explained here

Enrichments vs Internal homs

this gives an enrichement of $mathcal{C}$ over itself. In this question

Rigid monoidal and closed monoidal categories

it says that rigid monoidal categories are closed monoidal. So what does the self-enrichment of a rigid monoidal category look like?

ct.category theory – Can you define inductive data types over categories other than Set?

Can you define inductive data types over categories other than $mathbb{Set}$?

What does it look like? How about for a specific example like the category of monoids? If you were clever could you write a macro for inductive types other than over $mathbb{Set}$?

Silly Coq like pseudocode here

MonoidalInductive tree : Set :=
| mktree : prooflistismonoid -> list tree -> tree
.

Background

I was learning about well founded recursion again.

For the least upper bound $mu$ of an endofunctor $F$ from $C$ to $C$ we have a mapping.

$$ mathbb{map} : mathbb{Hom}_C(a, b) rightarrow mathbb{Hom}_C(F a, F b)$$

And a fold

$$ mathbb{fold} : mathbb{Hom}_C(F a, a) rightarrow mathbb{Hom}_C(mu F, a) $$

Many theorem provers provide a more pleasing built-in syntax for declaring inductive types. A simple list in Coq for example.

Inductive list (a : Set) : Set :=
| nil: list a
| cons: a -> list a -> list a
.

As I understand things this example could be viewed as defining the least upper bound of the fixed point of $mathbb{F} , a$ for $mathbb{F} , a , x = 1 + a * x$ within the category of $mathbb{Set}$.

Because these sort of inductive types take the fixed point of an endofunctor on $mathbb{Set}$ they are required to be strictly positive and not recurse contravariantly. If these types weren’t strictly positive they wouldn’t be structured around endofunctors on $mathbb{Set}$ they would be structured around somewhere other kind of functor.

So what about induction over categories other than $mathbb{Set}$?

Coinduction for example seems to make sense as induction over the opposite category. Monoidal induction sounds to me like it might be good for working with lists.

How to programmatically reindex only just categories with category id?

Can anyone help me on how to do programmatically reindexing just one category by using category id ?