• Resolved okayaelectric

    (@okayaelectric)


    Am attempting to use data from 365 to override the title and meta description fields for our SEO plugin.

    The page is called product-detail and I have it bound to the Product entity from 365.

    I am using this from the documentation to create the WordPress filter in functions.php — have copy/pasted and just changed to the fields I need:

    add_filter( ‘wordpresscrm_data_binding_columns’, function( $fields, $postContent, $postId ) {
    return array_merge(
    $fields,
    [ ‘productid’, ‘productnumber’, ‘name’, ‘description’, ‘oea_subject’ ] );
    }, 10, 3 );

    When referencing the entity binding line in my child theme template file:

    $currentRecord = ACRM()->binding->getEntity();

    It throws an error:

    Fatal error: Uncaught Error: Call to a member function getEntity() on null in /home/beta7327/public_html/wp-content/themes/vantage-child/functions.php

    Do I need to pass something into that getEntity function like the guid?

    Thank you for the assistance.
    Joe

Viewing 1 replies (of 1 total)
  • Plugin Contributor wizardist

    (@wizardist)

    Hi @okayaelectric

    wordpresscrm_data_binding_columns filter is pretty much deprecated.

    The right way to access binding is by calling ACRM()->getBinding()->getEntity().

    If you’re getting a non-NULL value, you can access productid, name, description and other fields right away.

    Thanks

Viewing 1 replies (of 1 total)
  • The topic ‘Entity binding in PHP code’ is closed to new replies.