Skip to content

[Feature]: Case-sensitive attribute updates and CSV Import attribute deletion capability - #4384

Merged
objecttothis merged 52 commits into
masterfrom
feature-case-sensitive-attribute-updates
Apr 9, 2026
Merged

objecttothis merged 52 commits into
masterfrom
feature-case-sensitive-attribute-updates

Conversation

@objecttothis

@objecttothis objecttothis commented Feb 25, 2026 •

Copy link
Copy Markdown
Member

This PR adds the following:

  • CSV imports where the only change to an attribute is the case of the letters will now update the attribute value.
  • Updates to the case of letters in attributes submitted to the items form will update the case in the database.
  • Fixes a bug where category as dropdown cannot be enabled.
  • Refactoring for PSR compliance.
  • PHPdocs added and updated.
  • Adding _DELETE_ in a attribute on a row in an items CSV import file will cause the attribute_link to be deleted for that item. It does not affect attribute_link rows where sale_id or receiving_id is not null.

Former behavior:

  1. When the attribute value existed regardless of case, the update would be skipped.
  2. Deletion of attribute_links was not possible in CSV imports

Summary by CodeRabbit

  • New Features

    • Added support for date and decimal attribute value types and helpers to map/validate them.
    • CSV import: per-row attribute persistence improvements and explicit attribute deletion via a sentinel.
  • Bug Fixes

    • More robust attribute and checkbox handling, orphaned-value cleanup, and stock-location persistence.
    • Improved CSV validation, early stock-location checks, and import rounding consistency.
  • Tests

    • Expanded CSV import tests and added test DB bootstrap for reliable isolation.

@objecttothis

Copy link
Copy Markdown
Member Author

@odiea do you want to give it a spin and see if you can find any problems?

@objecttothis

Copy link
Copy Markdown
Member Author

closing #3076

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for case-sensitive attribute updates in CSV imports and item forms, along with PSR compliance refactoring and a bug fix for the category dropdown feature. The core feature leverages MySQL's case-insensitive collation (utf8_general_ci) to detect existing attribute values, then compares them case-sensitively in PHP to update capitalization when needed.

Changes:

  • Added case-sensitive attribute value updates for both CSV imports and item forms by comparing stored values with new values and updating when only case differs
  • Refactored multiple methods from snake_case to camelCase naming (saveDefinition, getAttributeValue, saveAttributeValue, saveAttributeData, storeAttributeValue) for PSR compliance
  • Fixed category dropdown enable/disable logic by changing comparison from == 1 to truthy check
  • Added new helper function getAttributeDataType() to map attribute types to database column names
  • Added new method getAttributeValueByAttributeId() to retrieve attribute values by ID

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
app/Models/Attribute.php Refactored method names to camelCase, added getAttributeValueByAttributeId(), updated saveAttributeValue() with case-sensitive comparison logic, fixed PHPDoc formatting, updated saveAttributeLink() with null handling
app/Helpers/attribute_helper.php New helper file with getAttributeDataType() function to map attribute types to database columns
app/Controllers/Items.php Updated method calls to use new camelCase names, refactored CSV import methods, updated storeAttributeValue() with case-sensitive logic, improved fall-through comment syntax
app/Controllers/Config.php Fixed category dropdown enable logic from == 1 to truthy check, updated method call to saveDefinition()
app/Controllers/Attributes.php Updated method call to saveDefinition()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/Models/Attribute.php Resolved
Comment thread app/Controllers/Items.php Resolved
Comment thread app/Controllers/Config.php Resolved
Comment thread app/Models/Attribute.php Resolved
Comment thread app/Models/Attribute.php Resolved
Comment thread app/Controllers/Items.php Resolved
Comment thread app/Models/Attribute.php Resolved
Comment thread app/Models/Attribute.php Resolved
@odiea

odiea commented Feb 25, 2026 •

Copy link
Copy Markdown
Collaborator

@odiea do you want to give it a spin and see if you can find any problems?

What am I looking for and it appears not to save a Date now just 0's if even that? I have not tried importing just adding or updating a Date in Items. Date is working correctly now. TesT to Test is working properly now.

@objecttothis

Copy link
Copy Markdown
Member Author

@odiea do you want to give it a spin and see if you can find any problems?

What am I looking for and it appears not to save a Date now just 0's if even that? I have not tried importing just adding or updating a Date in Items.

Yeah, I'm pushing a fix for it.

@objecttothis

Copy link
Copy Markdown
Member Author

@odiea in the past if you added a TEXT or DROPDOWN attribute then in an item filled in a value with one capitalization (e.g., TEST), but after try to change just the capitalization (e.g., Test), the change would not happen. This PR fixes that.

@objecttothis
objecttothis marked this pull request as draft February 25, 2026 20:20
@objecttothis

Copy link
Copy Markdown
Member Author

I have a bug I'm working through before this PR can be merged. An exception is being thrown when adding some attributes. in the meantime I've converted it to a draft PR

@objecttothis
objecttothis removed the request for review from jekkos February 25, 2026 20:24
@objecttothis
objecttothis marked this pull request as ready for review February 26, 2026 08:48
@objecttothis

Copy link
Copy Markdown
Member Author

OK @odiea that date issue and a few others should be resolved now.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

@objecttothis

Copy link
Copy Markdown
Member Author

1042-1046: ⚠️ Potential issue | 🟠 Major

Tax and stock write failures are still invisible to the row state.

saveCSVRowAttributeData() now flips $isFailedRow, but save_tax_data() and save_inventory_quantities() are still fire-and-forget. A failed write in either helper never reaches failCodes, so this import can still report success for a partially persisted row.

@coderabbitai correct, but these changes are outside the scope of this PR. Create a new Github issue to make these changes as they will not be made in this PR which is already getting too large.

@coderabbitai

This comment was marked as resolved.

@objecttothis

Copy link
Copy Markdown
Member Author

@jekkos I think this is ready and I've resolved the relevant issues that coderabbitai brought up. Can you review and approve this if you don't see any issues?

@objecttothis

Copy link
Copy Markdown
Member Author

@jekkos should I wait for your review here or just merge. I'd like to get this merged so that I can move on to the plugins PR completely.

@jekkos

jekkos commented Apr 8, 2026

Copy link
Copy Markdown
Member

I will have a look in one hour if that is fine

@objecttothis

Copy link
Copy Markdown
Member Author

I will have a look in one hour if that is fine

Yeah that's fine. Thanks.

@jekkos

jekkos commented Apr 8, 2026

Copy link
Copy Markdown
Member

Looks mostly fine, maybe one question, we will only apply this logic then for newly imported data? So I guess it does not include a migration that cleans up existing data?
just for my information as it will be a changing behavior

jekkos
jekkos previously approved these changes Apr 8, 2026
Comment thread app/Config/Constants.php Resolved
@objecttothis

Copy link
Copy Markdown
Member Author

Looks mostly fine, maybe one question, we will only apply this logic then for newly imported data? So I guess it does not include a migration that cleans up existing data?
just for my information as it will be a changing behavior

For the capitalization sensitivity I'm not sure how you would migrate existing data since in some cases you want all caps.

For _DELETE_ passed in the CSV attributes to remove an attribute that to would be difficult to make a migration for since that is dependent on what attributes the user wants to remove.

Is there other new functionality I'm not thinking of that we could write a migration for to mass repair?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants