I’m developing a custom plugin for Shopware 6 and I’m extending the sw-customer-base-info component. I need to display the first name and last name of the user who created a customer.
In the database, the customer table has a created_by_id field. This ID corresponds to a record in the user table, which contains the first_name and last_name fields I need.
Here’s a simplified version of my current index.js:
import template from './sw-customer-base-info.html.twig';
const { Criteria } = Shopware.Data;
Shopware.Component.override('sw-customer-base-info', {
inject: ['repositoryFactory'],
template,
computed: {
userRepository() {
return this.repositoryFactory.create('user');
}
},
created() {
}
});
How can I modify this code to:
- Fetch the created_by_id from the current customer
- Use this ID to get the corresponding user’s first_name and last_name
- Make this data available in my component’s template
I’m new to Shopware 6 and its data handling, so a detailed explanation would be greatly appreciated.