Jump to content

Exporting products with description


Nazar

Recommended Posts

  • 7 months later...
  • 1 year later...

For prestashop 1.7

You can have it in module or update the code.

To update the code maybe you can try this.

1. src/PrestaShopBundle/Controller/Admin/ProductController.php .  -> exportAction(...) method
add in $headersData
'description' => $translator->trans('Description', array(), 'Admin.Global'),

2. src/Adapter/Product/AdminProductDataProvider.php  -> getCatalogProductList(...) method
add in $sqlSelect

'description' => array('table' => 'pl', 'field' => 'description', 'filtering' => ' %s '),
 

Screen Shot 2020-01-22 at 21.05.09.png

Screen Shot 2020-01-22 at 21.10.34.png

  • Like 1
Link to comment
Share on other sites

9 hours ago, ML Software Services said:

For prestashop 1.7

You can have it in module or update the code.

To update the code maybe you can try this.

1. src/PrestaShopBundle/Controller/Admin/ProductController.php .  -> exportAction(...) method
add in $headersData
'description' => $translator->trans('Description', array(), 'Admin.Global'),

2. src/Adapter/Product/AdminProductDataProvider.php  -> getCatalogProductList(...) method
add in $sqlSelect

'description' => array('table' => 'pl', 'field' => 'description', 'filtering' => ' %s '),
 

Screen Shot 2020-01-22 at 21.05.09.png

Screen Shot 2020-01-22 at 21.10.34.png

Thanks for your help.

File 2 is not an problem, but in File1 the texture is completly different:

public function exportAction()
    {
        return $this->get('prestashop.core.product.csv_exporter')->export();
    }

    /**
     * Set the Catalog filters values and redirect to the catalogAction.
     *
     * URL example: /product/catalog_filters/42/last/32
     *
     * @param int|string $quantity the quantity to set on the catalog filters persistence
     * @param string $active the activation state to set on the catalog filters persistence
     *
     * @return RedirectResponse
     */
    public function catalogFiltersAction($quantity = 'none', $active = 'none')
    {
        $quantity = urldecode($quantity);

        /** @var ProductInterfaceProvider $productProvider */
        $productProvider = $this->get('prestashop.core.admin.data_provider.product_interface');

        // we merge empty filter set with given values, to reset the other filters!
        $productProvider->persistFilterParameters(
            array_merge(
                AdminFilter::getProductCatalogEmptyFilter(),
                [
                    'filter_column_sav_quantity' => ($quantity == 'none') ? '' : $quantity,
                    'filter_column_active' => ($active == 'none') ? '' : $active,
                ]
            )
        );

        return $this->redirectToRoute('admin_product_catalog');
    }

    /**
     * @deprecated since 1.7.5.0, to be removed in 1.8 rely on CommonController::renderFieldAction
     *
     * @throws \OutOfBoundsException
     * @throws \LogicException
     * @throws \PrestaShopException
     */
    public function renderFieldAction($productId, $step, $fieldName)
    {
        @trigger_error(
            'This function is deprecated, use CommonController::renderFieldAction instead.',
            E_USER_DEPRECATED
        );

        $productAdapter = $this->get('prestashop.adapter.data_provider.product');
        $product = $productAdapter->getProduct($productId);
        $modelMapper = new AdminModelAdapter(
            $product,
            $this->get('prestashop.adapter.legacy.context'),
            $this->get('prestashop.adapter.admin.wrapper.product'),
            $this->get('prestashop.adapter.tools'),
            $productAdapter,
            $this->get('prestashop.adapter.data_provider.supplier'),
            $this->get('prestashop.adapter.data_provider.warehouse'),
            $this->get('prestashop.adapter.data_provider.feature'),
            $this->get('prestashop.adapter.data_provider.pack'),
            $this->get('prestashop.adapter.shop.context'),
            $this->get('prestashop.adapter.data_provider.tax'),
            $this->get('router')
        );
        $form = $this->createFormBuilder($modelMapper->getFormData());
        switch ($step) {
            case 'step1':
                $form->add('step1', 'PrestaShopBundle\Form\Admin\Product\ProductInformation');

                break;
            case 'step2':
                $form->add('step2', 'PrestaShopBundle\Form\Admin\Product\ProductPrice');

                break;
            case 'step3':
                $form->add('step3', 'PrestaShopBundle\Form\Admin\Product\ProductQuantity');

                break;
            case 'step4':
                $form->add('step4', 'PrestaShopBundle\Form\Admin\Product\ProductShipping');

                break;
            case 'step5':
                $form->add('step5', 'PrestaShopBundle\Form\Admin\Product\ProductSeo');

                break;
            case 'step6':
                $form->add('step6', 'PrestaShopBundle\Form\Admin\Product\ProductOptions');

                break;
            case 'default':
        }

        return $this->render('@PrestaShop/Admin/Common/_partials/_form_field.html.twig', [
            'form' => $form->getForm()->get($step)->get($fieldName)->createView(),
            'formId' => $step . '_' . $fieldName . '_rendered',
        ]);
    }
}

 

Link to comment
Share on other sites

40 minutes ago, nayonowe said:

Thanks for your help.

File 2 is not an problem, but in File1 the texture is completly different:


public function exportAction()
    {
        return $this->get('prestashop.core.product.csv_exporter')->export();
    }

    /**
     * Set the Catalog filters values and redirect to the catalogAction.
     *
     * URL example: /product/catalog_filters/42/last/32
     *
     * @param int|string $quantity the quantity to set on the catalog filters persistence
     * @param string $active the activation state to set on the catalog filters persistence
     *
     * @return RedirectResponse
     */
    public function catalogFiltersAction($quantity = 'none', $active = 'none')
    {
        $quantity = urldecode($quantity);

        /** @var ProductInterfaceProvider $productProvider */
        $productProvider = $this->get('prestashop.core.admin.data_provider.product_interface');

        // we merge empty filter set with given values, to reset the other filters!
        $productProvider->persistFilterParameters(
            array_merge(
                AdminFilter::getProductCatalogEmptyFilter(),
                [
                    'filter_column_sav_quantity' => ($quantity == 'none') ? '' : $quantity,
                    'filter_column_active' => ($active == 'none') ? '' : $active,
                ]
            )
        );

        return $this->redirectToRoute('admin_product_catalog');
    }

    /**
     * @deprecated since 1.7.5.0, to be removed in 1.8 rely on CommonController::renderFieldAction
     *
     * @throws \OutOfBoundsException
     * @throws \LogicException
     * @throws \PrestaShopException
     */
    public function renderFieldAction($productId, $step, $fieldName)
    {
        @trigger_error(
            'This function is deprecated, use CommonController::renderFieldAction instead.',
            E_USER_DEPRECATED
        );

        $productAdapter = $this->get('prestashop.adapter.data_provider.product');
        $product = $productAdapter->getProduct($productId);
        $modelMapper = new AdminModelAdapter(
            $product,
            $this->get('prestashop.adapter.legacy.context'),
            $this->get('prestashop.adapter.admin.wrapper.product'),
            $this->get('prestashop.adapter.tools'),
            $productAdapter,
            $this->get('prestashop.adapter.data_provider.supplier'),
            $this->get('prestashop.adapter.data_provider.warehouse'),
            $this->get('prestashop.adapter.data_provider.feature'),
            $this->get('prestashop.adapter.data_provider.pack'),
            $this->get('prestashop.adapter.shop.context'),
            $this->get('prestashop.adapter.data_provider.tax'),
            $this->get('router')
        );
        $form = $this->createFormBuilder($modelMapper->getFormData());
        switch ($step) {
            case 'step1':
                $form->add('step1', 'PrestaShopBundle\Form\Admin\Product\ProductInformation');

                break;
            case 'step2':
                $form->add('step2', 'PrestaShopBundle\Form\Admin\Product\ProductPrice');

                break;
            case 'step3':
                $form->add('step3', 'PrestaShopBundle\Form\Admin\Product\ProductQuantity');

                break;
            case 'step4':
                $form->add('step4', 'PrestaShopBundle\Form\Admin\Product\ProductShipping');

                break;
            case 'step5':
                $form->add('step5', 'PrestaShopBundle\Form\Admin\Product\ProductSeo');

                break;
            case 'step6':
                $form->add('step6', 'PrestaShopBundle\Form\Admin\Product\ProductOptions');

                break;
            case 'default':
        }

        return $this->render('@PrestaShop/Admin/Common/_partials/_form_field.html.twig', [
            'form' => $form->getForm()->get($step)->get($fieldName)->createView(),
            'formId' => $step . '_' . $fieldName . '_rendered',
        ]);
    }
}

 

Okay that was 1.7.3 did not noticed it.

You can find it in the latest prestashop in /src/Core/Product/ProductCsvExporter.php

I haven't tried this yet. Let me know if it works. If not I would love to try it in my side.
 

Edited by ML Software Services (see edit history)
Link to comment
Share on other sites

  • 1 year later...
On 1/23/2020 at 12:41 AM, MarlexLadag said:

Okay that was 1.7.3 did not noticed it.

You can find it in the latest prestashop in /src/Core/Product/ProductCsvExporter.php

I haven't tried this yet. Let me know if it works. If not I would love to try it in my side.

It works! Thank you MarlexLadag :)

Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...