cancel
Showing results for 
Search instead for 
Did you mean: 

($callback) must be a valid callback

($callback) must be a valid callback

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
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * Created By : FME
 */

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 for Create Custom Product Attribute using Data Patch.
 */
class EnableProductsList implements DataPatchInterface {

    /**
     * ModuleDataSetupInterface
     *
     * @var ModuleDataSetupInterface
     */
    private $moduleDataSetup;

    /**
     * EavSetupFactory
     *
     * @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() {
        /** @var EavSetup $eavSetup */
        $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\Catalog\Model\Product\Attribute\Source\Boolean::class,
            'global' => ScopedAttributeInterface::SCOPE_GLOBAL,
            'visible' => true,
            'required' => false,
            'user_defined' => false,
            'default' => 0,
            'searchable' => false,
            'filterable' => false,
            'comparable' => false,
            'visible_on_front' => false,
            'used_in_product_listing' => true,
            'unique' => false,
            'apply_to' => '',
        ]);
    }

    /**
     * {@inheritdoc}
     */
    public static function getDependencies() {
        return [];
    }

    /**
     * {@inheritdoc}
     */
    public function getAliases() {
        return [];
    }
}