When developing a custom shipping module for Magento 2.4.6, based on Adobe's documentation, you may encounter a fatal error during static content deployment:


## Fatal error: Type of MyModules\\CustomShipping1\Model\Carrier\Customshipping

$_isFixed must not be defined (as in class Magento\Shipping\Model\Carrier\AbstractCarrier) in /var/www/html/app/code/MyModules/CustomShipping1/Model/Carrier/Customshipping.php on line 18

The code for Customshipping.php is as follows:


<?php

declare(strict_types=1);

namespace MyModules\CustomShipping1\Model\Carrier;

use Magento\Framework\App\Config\ScopeConfigInterface;

use Magento\Quote\Model\Quote\Address\RateRequest;

use Magento\Quote\Model\Quote\Address\RateResult\Error;

use Magento\Quote\Model\Quote\Address\RateResult\Method;

use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory;

use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory;

use Magento\Shipping\Model\Rate\ResultFactory;

use Magento\Store\Model\ScopeInterface;

// ... (other code)

Solution

The $_isFixed property should not be defined in the custom shipping carrier class, as it is already defined in the AbstractCarrier class and should be inherited.

Remove the $_isFixed property from the custom shipping carrier class, as shown below:


// Remove the following line from the Customshipping class

protected $_isFixed = true;

// ... (other code)

After making this change, run a static content deployment, and the error should be resolved.