Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jsacksick created an issue. See original summary.

jsacksick’s picture

Status: Active » Needs review
FileSize
110.16 KB
12.73 KB

Attached patch for review... In a follow-up issue, we should add support for custom fields that were potentially added to price list items.

The CSV file generated is saved in the "temporary://" directory, and a link to it is displayed once the export process is complete.

This is how the UI looks like (Similar to the "Import prices" page:

jsacksick’s picture

Added tests coverage, and cleaned PriceListExportForm a bit.

jsacksick’s picture

Removed the validateForm() which was added in the previous patch, instead an empty CSV with just the headers will be created in case no prices exist.

  • jsacksick committed d51f3cc on 8.x-2.x
    Issue #3092961 by jsacksick: Allow exporting price list items via CSV.
    
jsacksick’s picture

Status: Needs review » Fixed

Committed!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

johnpicozzi’s picture

@Jsacksick - Thanks for this improvement! It works well. Could we add the variation title to the export?

jsacksick’s picture

@johnpicozzi: We could, what I did in a project that has custom field was that I overrode the route to use my form class:

    if ($route = $collection->get('entity.commerce_pricelist_item.export_form')) {
      $route->setDefault('_form', '\Drupal\YOUR_NAMESPACE\Form\PriceListItemExportForm');
    }

I'm doing that from a RouteSubscriber.

then you technically just have to override buildRow() and buildHeader(), as needed.

ben.hamelin’s picture

This patch was rolled against 8.x-2.x-beta3, mimicking the patch from #4 but with the entity label added.
Added this issue as well for the same approach but rolled against 8.x-2.x-dev: https://www.drupal.org/project/commerce_pricelist/issues/3101855