News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Getting child products ID's

Started by OliviaH, April 21, 2016, 16:58:06 PM

Previous topic - Next topic

OliviaH

How would I go about retrieving the product Id's of a parent products child products.
Is there already a variable that contains this data, or would it have to be retrieved from the database?

Joomla 3.0.12
Virtuemart 3.4.8
PHP 5.6.20

GJC Web Design

in  administrator\components\com_virtuemart\models\product.php

function getProductChildIds ($product_id) {

      if (empty($product_id)) {
         return array();
      }
      $db = JFactory::getDBO ();
      $db->setQuery (' SELECT virtuemart_product_id FROM `#__virtuemart_products` WHERE `product_parent_id` =' . (int)$product_id.' ORDER BY pordering, created_on ASC');

      return $db->loadColumn ();

   }

so something like


$productModel = VmModel::getModel('Product');

$products = $productModel->getProductChildIds( $product_id);
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation