Patch File: Bedard/CustomGloves/Setup/Patch/Data
<?php
namespace Bedard\CustomGloves\Setup\Patch\Data;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
class SetupCustomGloveProductAttribute implements DataPatchInterface, PatchVersionInterface
{
/** @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()
{
/** @var EavSetup $eavSetup */
$eavSetup = $this->eavSetupFactory->create(['setup' => $this->moduleDataSetup]);
$eavSetup->addAttribute('catalog_product', 'alternative_color', [
'type' => 'int',
'label' => 'Alternative Color',
'input' => 'select',
'used_in_product_listing' => true,
'user_defined' => true,
]);
}
/**
* {@inheritdoc}
*/
public static function getDependencies()
{
return [];
}
/**
* {@inheritdoc}
*/
public function getAliases()
{
return [];
}
}
Getting this error on setup:upgrade
Warning: call_user_func() expects parameter 1 to be a valid callback, class 'Bedard\CustomGloves\Setup\Patch\Data\SetupCustomGloveProductAttribute' not found in /home/customer/www/dom2sandbox.com/public_html/vendor/magento/framework/Setup/Patch/PatchRegistry.php on line 141
PatchRegistry:
/**
* Get patch dependencies.
*
* @param string $patch
* @return string[]
*/
private function getDependencies(string $patch)
{
$depInstances = [];
$deps = call_user_func([$patch, 'getDependencies']);
$this->cyclomaticStack[$patch] = true;
foreach ($deps as $dep) {
if (isset($this->cyclomaticStack[$dep])) {
throw new \LogicException("Cyclomatic dependency during patch installation");
}
$depInstance = $this->registerPatch($dep);
/**
* If a patch already have applied dependency - then we definitely know
* that all other dependencies in dependency chain are applied too, so we can skip this dep
*/
if (!$depInstance) {
continue;
}
$depInstances = array_replace($depInstances, $this->getDependencies($this->patches[$dep]));
$depInstances[$depInstance] = $depInstance;
}
unset($this->cyclomaticStack[$patch]);
return $depInstances;
}
2.3.3 Community Edition