Skip to content

What is the replacement for ‘require_once’ in PHP for Magento2 to resolve CodeSniffer test issue in Magento store?

I’m a beginner at PHP and Magento have developed a Magento2 extension and used this line code in it: require_once ‘/../knownuserv3/KnownUser.php’; But when I tried to put my extension in Magento Store, I got a series of test failure from… Read More »What is the replacement for ‘require_once’ in PHP for Magento2 to resolve CodeSniffer test issue in Magento store?

Error when compiling: Declaration of X must be compatible with Y

I’m new to Magento and working on upgrading an existing project to 2.4.3. When running php -dmemory_limit=5G bin/magento setup:di:compile I’m encountering an error: Fatal error: Declaration of XRecurringServiceModelExportMetadataProvider::getHeaders(MagentoFrameworkViewElementUiComponentInterface $component) must be compatible with MagentoUiModelExportMetadataProvider::getHeaders(MagentoFrameworkViewElementUiComponentInterface $component): array in /code/X/RecurringService/Model/Export/MetadataProvider.php on line… Read More »Error when compiling: Declaration of X must be compatible with Y

How to convert extension attribute type string to type object?

As type string:(but I need as an object) <?xml version=”1.0″?> <config xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:noNamespaceSchemaLocation=”urn:magento:framework:Api/etc/extension_attributes.xsd”> <extension_attributes for=”MagentoSalesApiDataOrderInterface”> <attribute code=”admin_user” type=”string”/> </extension_attributes> </config> should be something like: <attribute code=”admin_user” type=”pathtoobject”/> Plugin: <?php declare(strict_types=1); namespace CollinsOrderTrackingPlugin; use MagentoSalesApiDataOrderInterface; use MagentoSalesApiDataOrderSearchResultInterface; use MagentoSalesApiOrderRepositoryInterface; use CollinsOrderTrackingModelAttributesFactory;… Read More »How to convert extension attribute type string to type object?

Products “X” and “Y” have the same set of attribute values

I’m doing something like this foreach ($arrayItemsToReplace as $key => $item){ $product->getMediaGalleryImages()->removeItemByKey($key); $product->getMediaGalleryImages()->addItem($item); } if(count($arrayItemsToReplace)){ try{ $this->productRepository->save($product); But this is triggering me this error on the save action Products “X” and “Y” have the same set of attribute values. I’m… Read More »Products “X” and “Y” have the same set of attribute values