cancel
Showing results for 
Search instead for 
Did you mean: 

Type Error occurred when creating object:

Highlighted

Re: Type Error occurred when creating object:

Hi @Shoaib967 ,

 

Can you please try replacing your mass action node with follow and try to run all deployment commands.

 

<massaction name="listing_massaction">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
               <item name="selectProvider" xsi:type="string">components_listing.components_listing.components_columns.ids</item>
               <item name="component" xsi:type="string">Magento_Ui/js/grid/tree-massactions</item>
               <item name="indexField" xsi:type="string">component_id</item>
            </item>
        </argument>
        <action name="delete">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="type" xsi:type="string">delete</item>
                    <item name="label" xsi:type="string" translate="true">Delete</item>
                    <item name="url" xsi:type="url" path="*/*/massDelete"/>
                    <item name="confirm" xsi:type="array">
                      <item name="title" xsi:type="string" translate="true">Delete</item>
                      <item name="message" xsi:type="string" translate="true">Are you sure you wan't to delete selected items?</item>
                  </item>
              </item>
          </argument>
      </action>
  </massaction>

Try to replace the bold one entries with your appropriate values.

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!

Highlighted

Re: Type Error occurred when creating object:

Thanks @Nishu Jindal for the response, but sadly it is not working fine

Here is the GIT REPO if you can check it on your local?

Front end URL: /testimonial/index/add
https://github.com/shoaibgits/Testimonial

Highlighted

Re: Type Error occurred when creating object:

Hi @brasithaan45c7 , thnks for your time.

you can check the GIT Respository here: https://github.com/shoaibgits/Testimonial

Highlighted

Re: Type Error occurred when creating object:

Hi @Shoaib967 ,

 

I have checked the code and found that there are some issues in the code.

I have modified one file in your module and added one new file and now mass delete is working fine.

 

1.  Modified: app/code/Apriljune/Testimonial/etc/di.xml (Commented the rest code)

<type name="Apriljune\Testimonial\Model\ResourceModel\Testimonial\Grid\Collection">
        <arguments>
            <argument name="mainTable" xsi:type="string">apriljune_testimonial</argument>
            <argument name="eventPrefix" xsi:type="string">test_grid_collection</argument>
            <argument name="eventObject" xsi:type="string">test_grid_collection</argument>
            <argument name="resourceModel" xsi:type="string">Apriljune\Testimonial\Model\ResourceModel\Testimonial</argument>
        </arguments>
    </type>
    <type name="Magento\Framework\View\Element\UiComponent\DataProvider\CollectionFactory">
        <arguments>
            <argument name="collections" xsi:type="array">
                <item name="apriljune_testimonial_testimonial_listing_data_source" xsi:type="string">Apriljune\Testimonial\Model\ResourceModel\Testimonial\Grid\Collection</item>
            </argument>
        </arguments>
    </type>

2. Added:  app/code/Apriljune/Testimonial/Model/ResourceModel/Testimonial/Grid/Collection.php

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Apriljune\Testimonial\Model\ResourceModel\Testimonial\Grid;

use Magento\Framework\Api\Search\SearchResultInterface;
use Magento\Framework\Api\Search\AggregationInterface;
use Apriljune\Testimonial\Model\ResourceModel\Testimonial\Collection as TestimonialCollection;

/**
 * Class Collection
 * Collection for displaying grid of sales documents
 */
class Collection extends TestimonialCollection implements SearchResultInterface
{
    /**
     * @var AggregationInterface
     */
    protected $aggregations;

    /**
     * @param \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory
     * @param \Psr\Log\LoggerInterface $logger
     * @param \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy
     * @param \Magento\Framework\Event\ManagerInterface $eventManager
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Framework\EntityManager\MetadataPool $metadataPool
     * @param mixed|null $mainTable
     * @param string $eventPrefix
     * @param mixed $eventObject
     * @param mixed $resourceModel
     * @param string $model
     * @param null $connection
     * @param \Magento\Framework\Model\ResourceModel\Db\AbstractDb|null $resource
     *
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
     */
    public function __construct(
        \Magento\Framework\Data\Collection\EntityFactoryInterface $entityFactory,
        \Psr\Log\LoggerInterface $logger,
        \Magento\Framework\Data\Collection\Db\FetchStrategyInterface $fetchStrategy,
        \Magento\Framework\Event\ManagerInterface $eventManager,
        $mainTable,
        $eventPrefix,
        $eventObject,
        $resourceModel,
        $model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class,
        $connection = null,
        \Magento\Framework\Model\ResourceModel\Db\AbstractDb $resource = null
    ) {
        parent::__construct(
            $entityFactory,
            $logger,
            $fetchStrategy,
            $eventManager,
            $connection,
            $resource
        );
        $this->_eventPrefix = $eventPrefix;
        $this->_eventObject = $eventObject;
        $this->_init($model, $resourceModel);
        $this->setMainTable($mainTable);
    }

    /**
     * @return AggregationInterface
     */
    public function getAggregations()
    {
        return $this->aggregations;
    }

    /**
     * @param AggregationInterface $aggregations
     * @return $this
     */
    public function setAggregations($aggregations)
    {
        $this->aggregations = $aggregations;
        return $this;
    }

    /**
     * Get search criteria.
     *
     * @return \Magento\Framework\Api\SearchCriteriaInterface|null
     */
    public function getSearchCriteria()
    {
        return null;
    }

    /**
     * Set search criteria.
     *
     * @param \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria
     * @return $this
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function setSearchCriteria(\Magento\Framework\Api\SearchCriteriaInterface $searchCriteria = null)
    {
        return $this;
    }

    /**
     * Get total count.
     *
     * @return int
     */
    public function getTotalCount()
    {
        return $this->getSize();
    }

    /**
     * Set total count.
     *
     * @param int $totalCount
     * @return $this
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function setTotalCount($totalCount)
    {
        return $this;
    }

    /**
     * Set items list.
     *
     * @param \Magento\Framework\Api\ExtensibleDataInterface[] $items
     * @return $this
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function setItems(array $items = null)
    {
        return $this;
    }
}

Run the setup:di: compile command after deleting the generated/* folder.

Now mass delete is working fine.

 

Hope this helps you!

Problem Solved! Click Kudos & Accept as Solution!