#StackBounty: #magento2.3 #webapi #json-response Return JSON response in stead of JSON String

Bounty: 50

I’m working on building REST API which will return data of regions. API is working as expected but problem I’m facing is its returning response with JSON string and not able to parse that. Would like to get JSON response.

webapi.xml

    <route url="/V1/getRegions" method="GET">
        <service class="VendorModuleApiRegionsInterface" method="getRegions"/>
        <resources>
            <resource ref="self"/>
        </resources>
    </route>

Interface

<?php
namespace VendorModuleApi;

interface RegionsInterface
{
    /**
     * @return mixed
     */
    public function getRegions();
}

Next I added preference for interface and here’s that class.

<?php
declare(strict_types=1);
namespace VendorModuleModel;

use VendorModuleApiRegionsInterface;

class Regions implements RegionsInterface
{
    public function getRegions()
    {
        $data = [
            'status' => true,
            'message' => 'We will let you know!'
        ];

        return json_encode($data);

    }
}

When I’m triggering API with above code it returns like,

"{"status":true,"message":"We will let you know!"}"

I want response to be like,

{"status":true,"message":"We will let you know!"}

Any idea how to achieve this ?


Get this bounty!!!

#StackBounty: #magento2.3 #checkout #session #payment-gateway #magento2ccavenue Magento 2 Session Expire after return from payment gate…

Bounty: 50

We are facing the session expire issue, while, return from payment gateway.

We are integrated CCavenue Magento 2.3.4 Toolkit,

we are tried following ways

  1. Cache => somebody told maybe problem of cache content checkout and cart pages, so we tried to disable full page cache, then tried.
  2. Cookie Domain Mismatch => we are given the right hostname in cookie configuration.
  3. Stickie Session => we follow this blog, they suggested to use SameSite=lax.

Still, the session expires, after return from the payment gateway. we debug our toolkit, the session is there, before redirected to the payment gateway. after return from payment gateway only. session expires.

Suggest me, what is the issue and how to fix this.


Get this bounty!!!

#StackBounty: #magento2.3 #setup-di-compile #class-not-found Compile issue: Class AreProductsSalableInterface does not exist

Bounty: 50

Having issue in setup:di:compile and give below issue

enter image description here

Already checked: Magento 2 Setup di Compile Problem

Magento Vesion: 2.3.1

Update:

If i try with command bin/magento setup:di:compile -vvv, it gives below error

[root@server httpdocs]# bin/magento setup:di:compile -vvv
Compilation was started.
Area configuration aggregation... 5/7 [====================>-------]  71% 44 secs 287.0 MiB

In ClassReader.php line 35:

  [ReflectionException]
  Class MagentoInventorySalesApiApiAreProductsSalableInterface does not exist


Exception trace:
 () at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:35
 MagentoFrameworkCodeReaderClassReader->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassReaderDecorator.php:35
 MagentoSetupModuleDiCodeReaderClassReaderDecorator->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php:53
 MagentoSetupModuleDiCodeReaderDecoratorArea->getList() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:112
 MagentoSetupModuleDiAppTaskOperationArea->getDefinitionsCollection() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:87
 MagentoSetupModuleDiAppTaskOperationArea->doOperation() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php:56
 MagentoSetupModuleDiAppTaskManager->process() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php:206
 MagentoSetupConsoleCommandDiCompileCommand->execute() at /SITE_PATH/httpdocs/vendor/symfony/console/Command/Command.php:255
 SymfonyComponentConsoleCommandCommand->run() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:893
 SymfonyComponentConsoleApplication->doRunCommand() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:262
 SymfonyComponentConsoleApplication->doRun() at /SITE_PATH/httpdocs/vendor/magento/framework/Console/Cli.php:102
 MagentoFrameworkConsoleCli->doRun() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:145
 SymfonyComponentConsoleApplication->run() at /SITE_PATH/httpdocs/bin/magento:23

In ClassReader.php line 29:
  
[ReflectionException]
  Class MagentoInventorySalesApiApiAreProductsSalableInterface does not exist


Exception trace:
 () at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:29
 ReflectionParameter->getClass() at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:29
 MagentoFrameworkCodeReaderClassReader->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassReaderDecorator.php:35
 MagentoSetupModuleDiCodeReaderClassReaderDecorator->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php:53
 MagentoSetupModuleDiCodeReaderDecoratorArea->getList() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:112
 MagentoSetupModuleDiAppTaskOperationArea->getDefinitionsCollection() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:87
 MagentoSetupModuleDiAppTaskOperationArea->doOperation() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php:56
 MagentoSetupModuleDiAppTaskManager->process() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php:206
 MagentoSetupConsoleCommandDiCompileCommand->execute() at /SITE_PATH/httpdocs/vendor/symfony/console/Command/Command.php:255
 SymfonyComponentConsoleCommandCommand->run() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:893
 SymfonyComponentConsoleApplication->doRunCommand() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:262
 SymfonyComponentConsoleApplication->doRun() at /SITE_PATH/httpdocs/vendor/magento/framework/Console/Cli.php:102
 MagentoFrameworkConsoleCli->doRun() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:145
 SymfonyComponentConsoleApplication->run() at /SITE_PATH/httpdocs/bin/magento:23

setup:di:compile


Get this bounty!!!

#StackBounty: #magento2.3 #setup-di-compile #class-not-found Class AreProductsSalableInterface does not exist

Bounty: 50

Having issue in setup:di:compile and give below issue

enter image description here

Already checked: Magento 2 Setup di Compile Problem

Magento Vesion: 2.3.1

Update:

If i try with command bin/magento setup:di:compile -vvv, it gives below error

[root@server httpdocs]# bin/magento setup:di:compile -vvv
Compilation was started.
Area configuration aggregation... 5/7 [====================>-------]  71% 44 secs 287.0 MiB

In ClassReader.php line 35:

  [ReflectionException]
  Class MagentoInventorySalesApiApiAreProductsSalableInterface does not exist


Exception trace:
 () at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:35
 MagentoFrameworkCodeReaderClassReader->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassReaderDecorator.php:35
 MagentoSetupModuleDiCodeReaderClassReaderDecorator->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php:53
 MagentoSetupModuleDiCodeReaderDecoratorArea->getList() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:112
 MagentoSetupModuleDiAppTaskOperationArea->getDefinitionsCollection() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:87
 MagentoSetupModuleDiAppTaskOperationArea->doOperation() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php:56
 MagentoSetupModuleDiAppTaskManager->process() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php:206
 MagentoSetupConsoleCommandDiCompileCommand->execute() at /SITE_PATH/httpdocs/vendor/symfony/console/Command/Command.php:255
 SymfonyComponentConsoleCommandCommand->run() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:893
 SymfonyComponentConsoleApplication->doRunCommand() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:262
 SymfonyComponentConsoleApplication->doRun() at /SITE_PATH/httpdocs/vendor/magento/framework/Console/Cli.php:102
 MagentoFrameworkConsoleCli->doRun() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:145
 SymfonyComponentConsoleApplication->run() at /SITE_PATH/httpdocs/bin/magento:23

In ClassReader.php line 29:
  
[ReflectionException]
  Class MagentoInventorySalesApiApiAreProductsSalableInterface does not exist


Exception trace:
 () at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:29
 ReflectionParameter->getClass() at /SITE_PATH/httpdocs/vendor/magento/framework/Code/Reader/ClassReader.php:29
 MagentoFrameworkCodeReaderClassReader->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/ClassReaderDecorator.php:35
 MagentoSetupModuleDiCodeReaderClassReaderDecorator->getConstructor() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/Code/Reader/Decorator/Area.php:53
 MagentoSetupModuleDiCodeReaderDecoratorArea->getList() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:112
 MagentoSetupModuleDiAppTaskOperationArea->getDefinitionsCollection() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php:87
 MagentoSetupModuleDiAppTaskOperationArea->doOperation() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Module/Di/App/Task/Manager.php:56
 MagentoSetupModuleDiAppTaskManager->process() at /SITE_PATH/httpdocs/setup/src/Magento/Setup/Console/Command/DiCompileCommand.php:206
 MagentoSetupConsoleCommandDiCompileCommand->execute() at /SITE_PATH/httpdocs/vendor/symfony/console/Command/Command.php:255
 SymfonyComponentConsoleCommandCommand->run() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:893
 SymfonyComponentConsoleApplication->doRunCommand() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:262
 SymfonyComponentConsoleApplication->doRun() at /SITE_PATH/httpdocs/vendor/magento/framework/Console/Cli.php:102
 MagentoFrameworkConsoleCli->doRun() at /SITE_PATH/httpdocs/vendor/symfony/console/Application.php:145
 SymfonyComponentConsoleApplication->run() at /SITE_PATH/httpdocs/bin/magento:23

setup:di:compile


Get this bounty!!!

#StackBounty: #magento2.3 Type Error occurred when creating object Magento 2

Bounty: 50

I have created custom module and it’s working fine in Dev, but it’s not working on Production. It’s throwing Type error.

Type Error occurred when creating object:
TinyProductCustomizationModelResourceModelProductCollectionInterceptor,
Argument 5 passed to
TinyProductCustomizationModelResourceModelProductCollectionInterceptor::__construct()
must implement interface MagentoFrameworkDBAdapterAdapterInterface
or be null, string given, called in
/var/www/html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php
on line 121 [] [] [2021-01-11 10:11:47] report.CRITICAL: Type Error
occurred when creating object:
TinyProductCustomizationModelResourceModelProductCollectionInterceptor
[] []

My collection file as below

<?php

namespace TinyProductCustomizationModelResourceModelProduct;

use MagentoFrameworkModelResourceModelDbCollectionAbstractCollection;

class Collection extends AbstractCollection
{

    protected $_idFieldName = 'id';

    protected function _construct()
    {
        $this->_init(
            'TinyProductCustomizationModelProduct',
            'TinyProductCustomizationModelResourceModelProduct'
        );
        parent::_construct();
    }

}

and di.xml

<type name="MagentoFrameworkViewElementUiComponentDataProviderCollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="tiny_grid_data_source" xsi:type="string">TinyProductCustomizationModelResourceModelProductCollection</item>
            </argument>
        </arguments>
    </type>
    <virtualType name="TinyProductCustomizationModelResourceModelProductCollection" type="MagentoFrameworkViewElementUiComponentDataProviderSearchResult">
        <arguments>
            <argument name="mainTable" xsi:type="string">tiny_pro</argument>
            <argument name="resourceModel" xsi:type="string">TinyProductCustomizationModelResourceModelProduct</argument>
        </arguments>
    </virtualType>

Can you please help me on this?


Get this bounty!!!

#StackBounty: #magento2 #magento2.3 #import #sorting #product-sorting Column 'created_at' not imported

Bounty: 50

My goal is to sort products on the frontend from newest to oldest.

The products CSV file contains the created_at column (e.g. 2020-10-31 14:05:44). Format seems to be correct.

After the standard import, I’m looking in the catalog_product_entity table, and created_at is actually the import’s timestamp (e.g. 2020-11-28 17:38:48).

Am I looking at the wrong DB field? Is there some locale-specific formatting under the hood? (I’m importing for the ro store)

References

Versions: Magento 2.3.5-p1, PHP 7.3.24


Get this bounty!!!

#StackBounty: #magento2 #magento2.3 #import #sorting #product-sorting Column 'created_at' not imported

Bounty: 50

My goal is to sort products on the frontend from newest to oldest.

The products CSV file contains the created_at column (e.g. 2020-10-31 14:05:44). Format seems to be correct.

After the standard import, I’m looking in the catalog_product_entity table, and created_at is actually the import’s timestamp (e.g. 2020-11-28 17:38:48).

Am I looking at the wrong DB field? Is there some locale-specific formatting under the hood? (I’m importing for the ro store)

References

Versions: Magento 2.3.5-p1, PHP 7.3.24


Get this bounty!!!

#StackBounty: #magento2.3 #custom-attributes Magento 2: How to upload multiple images to Customer from Admin

Bounty: 50

Wanting to upload multiple images to a customer account via the admin. Below I’ve created a custom customer attribute that allows a single image / file upload, but how can I make this a multiple file upload?

InstallData.php

<?php

namespace MyCompanyMyModuleSetup;

use MagentoEavSetupEavSetupFactory;
use MagentoCustomerSetupCustomerSetupFactory;
use MagentoFrameworkSetupInstallDataInterface;
use MagentoFrameworkSetupModuleContextInterface;
use MagentoFrameworkSetupModuleDataSetupInterface;

class InstallData implements InstallDataInterface
{
  private $eavSetupFactory;
  private $customerSetupFactory;

  public function __construct(
    EavSetupFactory $eavSetupFactory,
    CustomerSetupFactory $customerSetupFactory
    )
    {
      $this->eavSetupFactory = $eavSetupFactory;
      $this->customerSetupFactory = $customerSetupFactory;
    }

    public function install(
      ModuleDataSetupInterface $setup,
      ModuleContextInterface $context
    ) {
      $setup->startSetup();

      $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);
      $customerSetup = $this->customerSetupFactory->create(['setup' => $setup]);

      $attributeCode = 'customer_logos';

      $customerSetup->addAttribute(
        MagentoCustomerModelCustomer::ENTITY,
        $attributeCode,
        [
          'type' => 'varchar',
          'input' => 'file',
          'label' => 'Customer Logos',
          'source' => '',
          'required' => false,
          'visible' => true,
          'position' => 200,
          'system' => false,
          'backend' => ''
        ]
      );

      // used this attribute in the following forms
      $attribute = $customerSetup->getEavConfig()
      ->getAttribute(MagentoCustomerModelCustomer::ENTITY, $attributeCode)
      ->addData(
        ['used_in_forms' => [
          'adminhtml_customer'
        ]
      ]);

      $attribute->save();
      $setup->endSetup();
    }
  }


Get this bounty!!!

#StackBounty: #magento2 #magento2.3 #import #sorting #product-sorting Column 'created_at' not imported

Bounty: 50

My goal is to sort products on the frontend from newest to oldest.

The products CSV file contains the created_at column (e.g. 2020-10-31 14:05:44). Format seems to be correct.

After the standard import, I’m looking in the catalog_product_entity table, and created_at is actually the import’s timestamp (e.g. 2020-11-28 17:38:48).

Am I looking at the wrong DB field? Is there some locale-specific formatting under the hood? (I’m importing for the ro store)

References

Versions: Magento 2.3.5-p1, PHP 7.3.24


Get this bounty!!!

#StackBounty: #magento2 #magento2.3 #import #sorting #product-sorting Column 'created_at' not imported

Bounty: 50

My goal is to sort products on the frontend from newest to oldest.

The products CSV file contains the created_at column (e.g. 2020-10-31 14:05:44). Format seems to be correct.

After the standard import, I’m looking in the catalog_product_entity table, and created_at is actually the import’s timestamp (e.g. 2020-11-28 17:38:48).

Am I looking at the wrong DB field? Is there some locale-specific formatting under the hood? (I’m importing for the ro store)

References

Versions: Magento 2.3.5-p1, PHP 7.3.24


Get this bounty!!!