public function CommerceProductEntityController::buildContent in Commerce Core 7
Builds a structured array representing the entity's content.
The content built for the entity will vary depending on the $view_mode parameter.
Parameters
$entity: An entity object.
$view_mode: View mode, e.g. 'full', 'teaser'...
$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
Return value
The renderable array.
Overrides DrupalCommerceEntityController::buildContent
File
- modules/
product/ includes/ commerce_product.controller.inc, line 189 - The controller for the product entity containing the CRUD operations.
Class
- CommerceProductEntityController
- The controller class for products contains methods for the product CRUD operations.
Code
public function buildContent($product, $view_mode = 'full', $langcode = NULL, $content = array()) {
// Prepare a reusable array representing the CSS file to attach to the view.
$attached = array(
'css' => array(
drupal_get_path('module', 'commerce_product') . '/theme/commerce_product.theme.css',
),
);
// Add the default fields inherent to the product entity.
$content['sku'] = array(
'#markup' => theme('commerce_product_sku', array(
'sku' => $product->sku,
'label' => t('SKU:'),
'product' => $product,
)),
'#attached' => $attached,
);
$content['title'] = array(
'#markup' => theme('commerce_product_title', array(
'title' => $product->title,
'label' => t('Title:'),
'product' => $product,
)),
'#attached' => $attached,
);
$content['status'] = array(
'#markup' => theme('commerce_product_status', array(
'status' => $product->status,
'label' => t('Status:'),
'product' => $product,
)),
'#attached' => $attached,
);
return parent::buildContent($product, $view_mode, $langcode, $content);
}