We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40098
    • 9 Posts
    This is my code, won't go into details, it's pretty self explanatory. All I want to do is get the TV of applications-product-link, from the resource with the ID of $englishSettingCousinApplicationProcessResourceID

    The value that $englishSettingCousinApplicationProcessResourceID returns, are valid published resources (returns 2145, and 2416)

    but whenever I try to get the the modResource object for the IDs (2145 and 2416) it returns a massive array like
    modDocument_mysql Object ( [_content] => [_output] => [_contextKey] => spanish


    just wondering if anyone had any information as to why?

    	//Get the cousin product resource ID from the english product, returns an id
    		$englishSettingCousinApplicationProcessResourceID = $modx->runSnippet('BabelTranslation', array(
    	   		'contextKey' => $originalContextKey,
    	   		'resourceId' => $englishApplicationsProductLink
    		));
    
    		$englishSettingCousinApplicationProcessResourceID = (int)$englishSettingCousinApplicationProcessResourceID;
    
    		$currentContextProduct = $modx->getObject('modResource', $englishSettingCousinApplicationProcessResourceID);
    		$applicationsProductLink = $currentContextProduct->getTVValue('applications-product-link');
    


    Any input is thoroughly appreciated!
    • Because that is the actual PHP class representing that row in the database.

      If you want to see the fields of the object and it's values only, use the toArray() method, e.g.
      var_dump($currentContextProduct->toArray());


      Regardless, what might be a more direct approach would be to get the value or render the output of the TV for the Resource id...
      $applicationsProductLinkTV = $modx->getObject('modTemplateVar', array('name' => 'applications-product-link'));
      return $applicationsProductLinkTV->renderOutput($englishSettingCousinApplicationProcessResourceID);

      This involves fewer queries and loading less data into memory.