Skip to content

Fix listing export custom field data - #2982

Closed
Arafat-plugins wants to merge 1 commit into
sovware:developmentfrom
Arafat-plugins:codex/fix-listing-export-custom-field-data
Closed

Fix listing export custom field data#2982
Arafat-plugins wants to merge 1 commit into
sovware:developmentfrom
Arafat-plugins:codex/fix-listing-export-custom-field-data

Conversation

@Arafat-plugins

Copy link
Copy Markdown
Contributor

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Security fix
  • Improvement
  • New Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Text changes
  • Other... Please describe:

Description

How to reproduce the issue or how to test the changes

This fixes the Directorist listing CSV export missing field data when exported listings do not all share the same directory/form field structure.

Previously, the exporter selected one row with the highest column count and used that row as the master CSV header. Fields that existed only on other listings or directories were dropped from the final CSV. This could hide saved listing data such as address, price, date, checkbox, and other custom field values.

This change builds the CSV header from the union of all exported row keys while preserving first-seen order, so fields from every exported listing are included. It also prepares serialized/array field values before CSV output, so checkbox/multi-value fields export as readable values instead of raw PHP serialized strings. CSV generation now uses PHP's native fputcsv() handling for safer escaping of commas, quotes, and multiline content.

  1. Create or use listings across directories/forms where one listing has fields that another listing does not have, for example address, pricing, date, and checkbox/custom fields.
  2. Go to Directorist -> Tools -> Export and export listings.
  3. Open the generated CSV.
  4. Verify the CSV header includes field columns from all exported listings, not only the row with the highest column count.
  5. Verify saved address, price, date, checkbox, and custom field values are present in their relevant listing rows.
  6. Verify checkbox/multi-value fields are exported as readable values instead of raw serialized strings.

Local verification performed:

  • php -l includes/classes/class-listings-export.php
  • vendor\bin\phpcs.bat --standard=phpcs.xml includes/classes/class-listings-export.php
  • git diff --check
  • Created a temporary local listing with address, price, date, and checkbox fields, exported via Directorist\Listings_Exporter::get_listings_data_as_csv_content(), verified all required columns and values were present, and confirmed serialized array output was not present. The temporary listing and directory were deleted after the test.

Any linked issues

Fixes # https://team.sovware.com/support/directorist/3270

Screenshot

  • N/A

Checklist

@Arafat-plugins

Copy link
Copy Markdown
Contributor Author

Superseded by #2983 to remove the codex/ branch prefix.

@Arafat-plugins
Arafat-plugins deleted the codex/fix-listing-export-custom-field-data branch August 30, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant