Custom module sort and search filter not working

I’ve created a custom module.

The sorting and search filter not working on the grid page.

<arguments>
<argument name="id" xsi:type="string">testGrid</argument>
<argument name="dataSource" xsi:type="object">VendorNameModuleNameModelResourceModelTestCollection</argument>
<argument name="default_sort" xsi:type="string">id</argument>
<argument name="default_dir" xsi:type="string">desc</argument>
<argument name="save_parameters_in_session" xsi:type="boolean">true</argument>
<argument name="use_ajax" xsi:type="boolean">true</argument>
<argument name="grid_url" xsi:type="url" path="*/*/grid"><param name="_current">1</param></argument>
</arguments>

table sort and search filter not working

How to create database and import sql dump using module?

I want to create a database and include SQL dump into that database, how to add it by using a custom module.

module – How to handle dynamic data in a script tag in head section for every page

I am absolutely new to Magento 2 (1 week in). I am trying to develop a Magento module that lets the admin specify a string (token) and when the admin saves the module I would like the token to inserted together with a tag into the section of each page.

If the admin changes the token and saves the config, it would be nice if it can update the same tag. Or even remove it if no token is specified.

The module UI is no problem and also the saving works fine and intercepting the token value (with PHP), but I got stuck on how exactly to control the that gets inserted.

I experimented with view/frontend/layout/default.xml and can influence the header, but this seems to be very static.

<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <script src="https://some-external-website.com/external-script.js" 
                data-token="token_value" 
                src_type="url"></script>
    </head>
</page>

So basically I would like to change the value in data-token (“token_value”) when the admin saves the config from the module, which I do from a PluginConfig file:

    ...
    public function aroundSave(MagentoConfigModelConfig $subject, callable $proceed) {
        // your custom logic
        $section = $subject->getSection();
        $returnValue = $proceed();
        $newConfigs = $this->scopeConfig->getValue($section);
        $token = $newConfigs("general")("token_value");

        // +++ here would like to write value of $token to the <script> tag +++
        
        return $returnValue;
    }
    ...

Any help appreciated!

magento2 – How to create my custom visual swatch color attribute in my own module Vendor/Module/Setup/Patch/Data/MyOwnColorAttribute?

I take from https://github.com/magento/magento2/blob/2.3/dev/tests/integration/testsuite/Magento/Swatches/_files/product_visual_swatch_attribute.php like example, but my own color attribute patch didn’t create any options if I add those parameters. This is my code:

<?php 
namespace VendorModuleSetupPatchData;

use MagentoCatalogModelProduct;
use MagentoEavModelEntityAttributeScopedAttributeInterface;
use MagentoEavModelEntityAttributeSourceTable;
use MagentoEavSetupEavSetupFactory;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoFrameworkSetupPatchDataPatchInterface;
use VendorModuleModelAttributeBackendColor as Backend;
use VendorModuleModelAttributeFrontendColor as Frontend;

class AddColorAttribute implements DataPatchInterface
{
    /**
     * @var ModuleDataSetupInterface
     */
    private $moduleDataSetup;

    /**
     * @var EavSetupFactory
     */
    private $eavSetupFactory;

    /**
     * @param ModuleDataSetupInterface $moduleDataSetup
     * @param EavSetupFactory $eavSetupFactory
     */
    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        EavSetupFactory $eavSetupFactory,
    ) {
        $this->moduleDataSetup = $moduleDataSetup;
        $this->eavSetupFactory = $eavSetupFactory;
    }

    /**
     * @inheritdoc
     */
    public function apply()
    {
        $this->moduleDataSetup->startSetup();
        $eavSetup = $this->eavSetupFactory->create();
        $eavSetup->addAttribute(Product::ENTITY, 'visual_swatch_color_attribute', (
            'type' => 'int',
            'label' => 'Visual Swatch Color Attribute',
            'input' => 'select',
            'frontend' => Frontend::class,
            'backend' => Backend::class,
            'source' => Table::class,
            'required' => false,
            'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
            'visible' => true,
            'is_used_in_grid' => true,
            'is_visible_in_grid' => true,
            'is_filterable_in_grid' => true,
            'user_defined' => true,
            'searchable' => true,
            'filterable' => true,
            'comparable' => true,
            'visible_on_front' => true,
            'used_in_product_listing' => true,
            'is_html_alowed_on_front' => true,
            'unique' => false,
            'swatch_input_type' => 'visual',
            'swatchvisual' => (
                'value' => (
                    'Obsidian' => '#3a322d',
                    'Pure' => '#0000ff',
                    'Crimson' => '#dc143c',
                    'Emerald' => '#50c878',
                    'Ametyst' => '#9966cc',
                ),
            ),
            'optionvisual' => (
                'values' => (
                    'Obsidian' => ('Obsidian'),
                    'Pure' => ('Pure'),
                    'Crimson' => ('Crimson'),
                    'Emerald' => ('Emerald'),
                    'Ametyst' => ('Ametyst'),
                ),
            ),
            'default' => '1'
        ));

        $eavSetup->addAttributeToGroup(
            MagentoCatalogModelProduct::ENTITY,
            'Default',
            'Product Details',
            'visual_swatch_color_attribute',
            18
        );
        $this->moduleDataSetup->endSetup();
    }

    /**
     * @inheritdoc
     */
    public static function getDependencies(): array
    {
        return ();
    }

    /**
     * @inheritdoc
     */
    public function getAliases(): array
    {
        return ();
    }
}

CDN module: wrong settings broke my site

I installed the cdn module from:

https://www.drupal.org/project/cdn

and in the UI i setted a wrong cdn path.

now my site is broken it can load css and js. end i cannot disable the module from the UI.

i have admin access at the server but i cant figure out how to disable cdn, there is a cdn,settings.yml but it seems that the option isnt there.

i cant find any documentation for the module… can you please help me?

magento2 – Issue with get product name in custom module

I try to display product name in custom module; I paste below code but get issue:

Exception #0 (Exception): Notice: Undefined variable: _product in /home/fsgroup/domains/domainss.pl/public_html/app/code/My/Module/view/frontend/templates/vendor.phtml on line

code:

 <?php
    $vendorData = $block->getVendorData();
    $_productNameStripped = $block->stripTags($_product->getName(), null, true);
    if ($vendorData->getId()) {?>
        <div class="vendor-info">                                    <a class="product-item-link"
                                           href="<?= /* @escapeNotVerified */ $_product->getProductUrl() ?>"
                                           title="<?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>">
                                            <?= /* @escapeNotVerified */ $_helper->productAttribute($_product, $_product->getName(), 'name'); ?>
                                        </a> <?= /* @noEscape */ __('od').' : ';?>
            <a href=<?= /* @noEscape */ $vendorData->getVendorShopUrl();?>><?= /* @noEscape */ $vendorData->getPublicName(); ?></a>
        </div>
    <?php } ?>

is issue here with variable:

$_productNameStripped = $block->stripTags($_product->getName(), null, true);

I copy this from list.phtml and here working correct. What should I add more here?

8 – Is it possible to use only one module for multiple Site Studio (Cohesion) elements?

I’m creating custom elements to use within Acquia Site Studio/Cohesion (following this), but one majorly inconvenient thing is that you have to create a whole new module for each element. I’m trying to integrate an entire preexisting design system with several components, so registering and enabling modules for each of them is a bit of a pain.

I noticed that all of Site Studio’s stock elements use only one module, so it gave me the idea to do the same. However, those elements aren’t like custom ones, in the sense that they’re retrieved from an API and the markup is generated at runtime. So I can’t exactly just follow the same process.

So far what I’ve tried is creating a single “Components Package” module, then defining multiple classes for each element inside the src/Plugin/CustomElement/ComponentPackage.php file. But the class has to match the file name, so that doesn’t work.

I’ve read through all of Acquia’s documentation and there’s nothing that addresses this, so I fear it may not be possible. But their documentation lacks in several areas, so maybe it is. Any help would be much appreciated.

magento2.3 – Composer can’t install any module due to “Your requirements could not be resolved to an installable set of packages”

Running 2.3.6
When I try to install any module via composer I get the following error:

 ()$ COMPOSER_MEMORY_LIMIT=-1 composer require stripe/stripe-php:^7
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
./composer.json has been updated
Loading composer repositories with package information
Warning from https://repo.packagist.org: You are using an outdated version of Composer. Composer 2 is now available and you should upgrade. See https://getcomposer.org/2
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove magento/product-community-edition 2.3.6
    - Conclusion: don't install magento/product-community-edition 2.3.6
    - Installation request for magento/product-community-edition 2.3.6 -> satisfiable by magento/product-community-edition(2.3.6).
    - Installation request for veriteworks/cookiefix ^3.0 -> satisfiable by veriteworks/cookiefix(3.0.0).
    - Conclusion: don't install magento/framework 102.0.6-p1
    - magento/product-community-edition 2.3.6 requires laminas/laminas-code ~3.3.0 -> satisfiable by laminas/laminas-code(3.3.2, 3.3.0, 3.3.1).
    - Can only install one of: laminas/laminas-code(3.4.1, 3.3.0).
    - Can only install one of: laminas/laminas-code(3.4.1, 3.3.1).
    - Can only install one of: laminas/laminas-code(3.4.1, 3.3.2).
    - Can only install one of: laminas/laminas-code(3.4.1, 3.3.2).
    - Can only install one of: laminas/laminas-code(3.4.1, 3.3.2).
    - Conclusion: install magento/framework 102.0.6-p1|install laminas/laminas-code 3.4.1


Installation failed, reverting ./composer.json to its original content.

Is it possible i made a mess since few days ago (before that I think everything was working fine) and then I launched “composer dump-autoload -o” for some reason? If it’s that, is it possible to get back to previous version?

higher algebra – Is the rank of free module spectra unique?

$pi_0: Spto Ab$ is a direct sum preserving functor, and it sends $E_1$-ring spectra to rings, and modules over them to modules over them.

In particular you get a functor $pi_0: Mod_Rto Mod_{pi_0(R)}$. If $R^nsimeq R^m$ as $R$-modules, then $pi_0(R)^ncong pi_0(R)^m$ as $pi_0(R)$-modules. So if $pi_0(R)$ is commutative and nonzero (which is a much weaker hypothesis than $R$ having an $E_infty$-structure), this implies $n=m$.

More generally, it suffices that $pi_0(R)$ have the invariant basis property.

Note that conversely, if $pi_0(R)$ does not have the invariant basis property, we can find inverse nonsquare matrices $M,N$ with coefficients in $pi_0(R)$, and you can view them as elements of $pi_0map_R(R^n,R^m)$ ($pi_0map_R(R^m,R^n)$ respectively), and their matrix product corresponds to the composition up to homotopy, so that $R^nsimeq R^m$ as $R$-modules.

So it’s an “if and only if” situation with $pi_0(R)$.

A related claim is the fact that group-completion $K$-theory only sees $pi_0$, namely if $R$ is a ring spectrum, then the group-completion $K$-theory of projective $R$-modules (summands of $R^n$ for some finite $n$, no shifts) is the same as that of $tau_{geq 0}R$, which is the same as that of $pi_0(R)$.

nodes – Implementing hidden content parts (as in old “Hidden Content” module)

There is (long unsupported) “Hidden Content” module, allowing to insert content blocks visible by certain roles only, i.e. like below:

(hidden role="Role Name")
   ...content visible to "Role Name" role only
(/hidden)

I browsed through related modules (from “Content Access Control” etc), but see no good match for this module’s capabilities. Are there any simple means to achieve the above without either re-implementing the module for Drupal 9 or using inline PHP?

“Paragraphs Access Control” looks somewhat suitable, but it requires creating quite a complex structure only to restrict access to text blocks.