-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Producers for Taxonomy terms and Menu items #9
Comments
You are right, I started implementing the taxonomy term producer but never finished since it was out of our scope. You can try to create a taxonomy term producer and report here the issues you encounter. |
To answer your question actually $producer = ProducerFactory::create('tags', 'taxonomy_term_producer')
->setBackend('filesystem')
->setEntityBundle('tags')
->setResourceSchema('tags')
->setMapping('name', 'name'); You can try if this works as well. |
Actually this works, I've tested it, just creation and update dates are empty since this information is not present on the term itself in Drupal to start with: BackendFactory::create('backend', 'memory_backend')->setResourceSchema('article');
ResourceSchemaFactory::create('tag')->setField('name', 'Name');
$tag_producer = ProducerFactory::create('tag', 'taxonomy_term_producer')
->setBackend('backend')
->setEntityBundle('tags')
->setResourceSchema('tag')
->setMapping('name', 'name');
$term = taxonomy_term_load(1);
$tag = $tag_producer->build($term); |
Thanks a lot Antonio, that's really great. |
That error message you got on the UI or using the API? |
Using the API. |
Good morning Antonio, I rolled back the changes to the db, and re-ran the taxonomy term export, in order to get the error message back, in case it might be useful to you:
The taxonomies that I'm exporting have custom fields, which are at this moment set to non translatable. What is weird is that it manages to export quite a lot of terms from the same taxonomy before running into the specific term that throws the error. I'm curious about the UI way. I couldn't find it yet. If you tell me where to start on the UI, I can probably find my way. Thanks for all the help! |
Can you post here the API calls you use to create the export? On Fri, Mar 4, 2016 at 10:44 AM, Ivan Chaer [email protected]
|
I'm using a loop to export all terms from all taxonomies, but I can get the same error if I just run your example on the term id that throws the error (1146): use Drupal\integration_producer\ProducerFactory;
use Drupal\integration\Backend\BackendFactory;
use Drupal\integration\ResourceSchema\ResourceSchemaFactory;
BackendFactory::create('backend', 'memory_backend')->setResourceSchema('article');
ResourceSchemaFactory::create('tag')->setField('name', 'Name');
$tag_producer = ProducerFactory::create('tag', 'taxonomy_term_producer')
->setBackend('backend')
->setEntityBundle('tags')
->setResourceSchema('tag')
->setMapping('name', 'name');
$term = taxonomy_term_load(1146);
$tag = $tag_producer->build($term); |
That's wicked... could you paste a |
Indeed! :D stdClass::__set_state(array(
'tid' => '1146',
'vid' => '3',
'name' => 'Transport infographics',
'description' => '',
'format' => 'full_html',
'weight' => '7',
'uuid' => '61f0a207-2353-4aaf-8953-eeb0c0c9dfa5',
'language' => 'und',
'i18n_tsid' => '0',
'vocabulary_machine_name' => 'transport_categories',
'field_internal_id' =>
array (
'und' =>
array (
0 =>
array (
'value' => 'transport-infographics',
'format' => NULL,
'safe_value' => 'transport-infographics',
),
),
),
'field_tr_site_section' =>
array (
'und' =>
array (
0 =>
array (
'value' => 'facts-fundings',
'format' => NULL,
'safe_value' => 'facts-fundings',
),
),
),
'translations' =>
stdClass::__set_state(array(
'original' => 'en',
'data' =>
array (
'en' =>
array (
'entity_type' => 'taxonomy_term',
'entity_id' => '1146',
'revision_id' => '1146',
'language' => 'en',
'source' => '',
'uid' => '1',
'status' => '1',
'translate' => '0',
'created' => '1455713063',
'changed' => '1455713063',
),
),
)),
'rdf_mapping' =>
array (
'rdftype' =>
array (
0 => 'skos:Concept',
),
'name' =>
array (
'predicates' =>
array (
0 => 'rdfs:label',
1 => 'skos:prefLabel',
),
),
'description' =>
array (
'predicates' =>
array (
0 => 'skos:definition',
),
),
'vid' =>
array (
'predicates' =>
array (
0 => 'skos:inScheme',
),
'type' => 'rel',
),
'parent' =>
array (
'predicates' =>
array (
0 => 'skos:broader',
),
'type' => 'rel',
),
),
'path' =>
array (
'pathauto' => '1',
),
)) |
And this is a term that was exported without problems: stdClass::__set_state(array(
'tid' => '1188',
'vid' => '3',
'name' => 'ten-t-days-2010',
'description' => NULL,
'format' => NULL,
'weight' => '0',
'uuid' => '1f3aa50d-837e-4bc2-8447-5279e6ece4ff',
'language' => 'und',
'i18n_tsid' => '0',
'vocabulary_machine_name' => 'transport_categories',
'field_internal_id' =>
array (
),
'field_tr_site_section' =>
array (
),
'translations' =>
stdClass::__set_state(array(
'original' => 'und',
'data' =>
array (
'und' =>
array (
'entity_type' => 'taxonomy_term',
'entity_id' => '1188',
'revision_id' => '1188',
'language' => 'und',
'source' => '',
'uid' => '1',
'status' => '1',
'translate' => '0',
'created' => '1456407817',
'changed' => '1456407817',
),
),
)),
'rdf_mapping' =>
array (
'rdftype' =>
array (
0 => 'skos:Concept',
),
'name' =>
array (
'predicates' =>
array (
0 => 'rdfs:label',
1 => 'skos:prefLabel',
),
),
'description' =>
array (
'predicates' =>
array (
0 => 'skos:definition',
),
),
'vid' =>
array (
'predicates' =>
array (
0 => 'skos:inScheme',
),
'type' => 'rel',
),
'parent' =>
array (
'predicates' =>
array (
0 => 'skos:broader',
),
'type' => 'rel',
),
),
)) |
The problem is with the original language being |
No, for now the taxonomies are set to:
When I made it translatable yesterday evening, the error went away. I rolled back the db today as you were interested in the error message, but it's ok for me to make them translatable. |
Ah ok I see, that's good to know. Thanks! On Fri, Mar 4, 2016 at 11:19 AM, Ivan Chaer [email protected]
|
After struggling with trying to create a producer for menu links, I got under the impression that the Integration module focus on exporting entities (like nodes and taxonomies), but that perhaps it wouldn't be suited to export menu items. Am I wrong? Btw, I found the producer UI url just recently, while reading the code: Foolish, I didn't think of looking into config... Maybe would be good to add to this url to the producer documentation? (I was going to open a new issue for this, but since I mentioned this previously on this issue, I just added it here. Let me know if you prefer to make a new issue on Github for this.) Thanks! |
Hi Antonio,
I'm interested in implementing a taxonomy term producer and a menu item producer.
Any tips and insights on how to approach this task are most welcome.
Regarding taxonomies, I noticed that besides the
NodeProducer
class, the Integration Producer module also has aTaxonomyTermProducer
class.I'm wondering if there is a way to adapt the Producer example by configuring the
ProducerFactory
to use thetaxonomy_term_producer
instead of the defaultnode_producer
, or if I should proceed in a different way.Any help will be much appreciated.
Many thanks,
Ivan
The text was updated successfully, but these errors were encountered: