$title, 'edit' => trim( $data[1] ?? '' ), 'format_guid' => 'plain', ]; if( !$component->store( $pHash ) ) { return false; } // Part number xref (#PN) $partNumber = trim( $data[2] ?? '' ); if( $partNumber !== '' ) { $xrefHash = [ 'content_id' => $component->mContentId, 'source' => '#PN', 'edit' => $partNumber, 'fAddXref' => 1, ]; $component->storeXref( $xrefHash ); } // Quantity xref $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, 'source' => $qtySrc, 'edit' => $qtyValue, 'fAddXref' => 1, ]; $component->storeXref( $xrefHash ); } return true; }