Skip to content

Instantly share code, notes, and snippets.

@felipecruz
Last active June 10, 2016 17:43
Show Gist options
  • Save felipecruz/1dfe11a21273a96192d8b43c6bb26414 to your computer and use it in GitHub Desktop.
Save felipecruz/1dfe11a21273a96192d8b43c6bb26414 to your computer and use it in GitHub Desktop.
<?php
$attributes_str = "small_image";
function IsNullOrEmptyString($value){
return (!isset($value) || trim($value)==='');
}
foreach (explode(",", $attributes_str) as $attr) {
$meta_tag = '<meta name="product:%s" content="%s" />';
$value = $product->getData();
if (!IsNullOrEmptyString($value)) {
echo sprintf($meta_tag, $attr, $product->getAttributeText($attr));
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment