0

I am developing an Ecommerce site and I am using Drupal-commerce module for it. I have an issue regarding loading the contents of a product which is: How can I programmatically get the contents of all the products in a particular product type?

2 Answers 2

0

This can be done with an EntityFieldQuery:

<?php
  $query = new EntityFieldQuery();
  $result = $query->entityCondition('entity_type', 'node')
    ->entityCondition('bundle', 'product')
    ->execute();
  $nodes = node_load_multiple(array_keys($result['node']));
?>
0
-1

This code will help you.

$banner_query = db_select('node','n');
$banner_query->innerJoin('field_data_field_weight','w','w.entity_id = n.nid');  // join with another table
$banner_query->fields('n',array('nid')); 
$banner_query->fields('w',array('field_weight_value'));
$banner_query->condition('n.status',1,'=');  
$banner_query->condition('n.type','skin_and_hair_banners','=');
$banner_query->orderBy('w.field_weight_value','ASC');
$banner_res = $banner_query->execute();

while($banner_fetch = $banner_res->fetchObject()){
    $banner_load = node_load($banner_fetch->nid);
    echo "<pre>"; print_r($banner_load)
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.