1

My extension is failing varnish test over and over again and the only visible error i have found in the error reports is

call_user_func(): Argument #1 ($callback) must be a valid callback, class " \n FME\ProductsList\Setup\Patch\Data\EnableProductsList" not found#0 /app/vend \n or/magento/framework/Setup/Patch/PatchRegistry.php(141): call_user_func(Arr \n ay) \n #1 /app/vendor/magento/framework/Setup/Patch/PatchRegistry.php(207): Magent \n o\Framework\Setup\Patch\PatchRegistry->getDependencies('FME\\ProductsLis... \n ')

Here is my code for Data Patch which seems to be fine

<?php
declare (strict_types = 1);
namespace FME\ProductsList\Setup\Patch\Data;

use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Setup\EavSetupFactory;
use Magento\Framework\Setup\ModuleDataSetupInterface;
use Magento\Framework\Setup\Patch\DataPatchInterface;

class EnableProductsList implements DataPatchInterface
{
    private $moduleDataSetup;
    private $eavSetupFactory;
    public function __construct(
        ModuleDataSetupInterface $moduleDataSetup,
        EavSetupFactory $eavSetupFactory
    ) {
        $this->moduleDataSetup = $moduleDataSetup;
        $this->eavSetupFactory = $eavSetupFactory;
    }
    public function apply()
    {
        $this->moduleDataSetup->startSetup();
        $eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
        $eavSetup->addAttribute(
            'catalog_product', 'enable_productslist', [
                'type' => 'int',
                'backend' => '',
                'frontend' => '',
                'label' => 'Enable Product Export',
                'input' => 'boolean',
                'class' => '',
                'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
                'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
                'visible' => true,
                'required' => false,
                'user_defined' => false,
                'default' => 0,
                'note'     => 'This setting was added by FME Product List',
                'searchable' => false,
                'filterable' => false,
                'comparable' => false,
                'visible_on_front' => false,
                'used_in_product_listing' => true,
                'unique' => false,
                'apply_to' => '',
            ]
        );
        $this->moduleDataSetup->endSetup();
    }
    public static function getDependencies()
    {
        return [];
    }
    public function getAliases()
    {
        return [];
    }
}
                                            

2 Answers 2

1

The problem was in the composer.json file by mistakenly I have given wrong spellings in psr-4 section

"psr-4": {
    "FME\\ProducstList\\": ""
} 

It should be

"psr-4": {
    "FME\\ProductsList\\": ""
} 
0

I was also facing the same issue in my custom module installation from the composer. After that, I reviewed my module composer.json and we found that the psr-4.

"name": "prince/Learningmodule",
"psr-4": {
        "Prince\\Learningmodule\\": ""
    }
  • The psr-4 values are wrong because My Moduele Vendor name and module name are as

    • Vendor: Prince
    • Module: LearningModule

_Updated code:

"name": "prince/Learningmodule",
"psr-4": {
        "Prince\\LearningModule\\": ""
    }

Please be careful about this naming of PSR-4 It maps your module.

Hope this helps you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.