$title, 'edit' => trim( $data[1] ?? '' ), 'format_guid' => 'plain', ]; if( !$component->store( $pHash ) ) { return false; } // Supplier xref (#SUP) — part number in xkey; xref (contact_id) left empty for manual linking $partNumber = trim( $data[2] ?? '' ); if( $partNumber !== '' ) { $xrefHash = [ 'content_id' => $component->mContentId, 'item' => '#SUP', 'xkey' => $partNumber, 'fAddXref' => 1, ]; $component->storeXref( $xrefHash ); } // Quantity xref (SGL/PCK/SHT/VOL) $qtyValue = isset( $data[3] ) && is_numeric( trim( $data[3] ) ) ? (float)trim( $data[3] ) : null; $qtySrc = strtoupper( trim( $data[4] ?? 'SGL' ) ); if( !in_array( $qtySrc, [ 'SGL', 'PCK', 'SHT', 'VOL' ] ) ) { $qtySrc = 'SGL'; } if( $qtyValue !== null ) { $xrefHash = [ 'content_id' => $component->mContentId, 'item' => $qtySrc, 'xkey' => $qtyValue, 'fAddXref' => 1, ]; $component->storeXref( $xrefHash ); } return true; }