3

In magento 2 admin panel, at product list grid area, i want to add one more grid with date, that date define product create date. so we get idea at which time product was created.

And i also want to add by whom it created, we have so many admin so we want to know by whom that product created.

So we need that 2 column on product grid area in admin side.

4
  • Explain your question a bit more as it is hard to understand your query with this minimum content Commented Dec 14, 2017 at 11:41
  • @N.KarthicKannan, In magento 2 admin panel, at product list grid area, i want to add one more grid with date, that date define product create date. so we get idea at which time product was created. and i also want to add by whom it created, we have so many admin so we want to know by whom that product created. so we need that 2 column on product grid area in admin side.
    – JACK
    Commented Dec 14, 2017 at 11:45
  • @JACK can you take a screenshot? Commented Dec 15, 2017 at 8:33
  • @KhoaTruongDinh which screenshot? in admin of magento 2 on product catalog list page. i want 2 column. 1)Created Date 2)Created By I don't think it need any screenshot.
    – JACK
    Commented Dec 15, 2017 at 10:22

2 Answers 2

5
+50

We can find the Create At field in table: catalog_product_entity.

So, for this field, we only need to show it:

For example:

app/code/Vendor/Catalog/view/adminhtml/ui_component/product_listing.xml

<?xml version="1.0" encoding="UTF-8"?>

<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <columns name="product_columns" class="Magento\Catalog\Ui\Component\Listing\Columns">
        <column name="created_at" component="Magento_Ui/js/grid/columns/date">
             <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">dateRange</item>
                    <item name="dataType" xsi:type="string">date</item>
                    <item name="label" xsi:type="string" translate="true">Created Date</item>
                    <item name="sortOrder" xsi:type="number">71</item>
                </item>
            </argument>
        </column>
    </columns>
</listing>

Remember to create registration and module.xml.

[Note]

The create_at result will be different from database. Because

As we use default value CURRENT_TIMESTAMP for TIMESTAMP type columns we need to set GMT timezone

\Magento\Framework\DB\Adapter\Pdo\Mysql::connect()

    $this->_connection->query("SET time_zone = '+00:00'");
2
  • Thanks for answer @khoa, Can you guide me for Created by column?
    – JACK
    Commented Dec 19, 2017 at 6:47
  • @JACK in this case, hard for us. Because in some cases we cannot track the Created by. For example, products are created by CSV or via command line. But, I have a guide for you. We need to create a new product attribute Created By, and then add it via ui component like above. Using beforeSave plugin to get the current session for Created By. Commented Dec 19, 2017 at 6:55
0

You can add this code to filter product by created date in Magento.

/MagentoRoot/vendor/magento/module-catalog/view/adminhtml/ui_component/product_listing.xml

<column name="created_at">
   <argument name="data" xsi:type="array">
        <item name="config" xsi:type="array">
            <item name="filter" xsi:type="string">dateRange</item>
            <item name="editor" xsi:type="string">text</item>
            <item name="label" xsi:type="string" translate="true">Created At</item>
            <item name="sortOrder" xsi:type="number">60</item>
        </item>
    </argument>
</column 

Or follow this link : Magento 2 add product created at date to filter product in admin grid

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.