Quote from: hazael on October 10, 2024, 23:48:00 PMSuch websites were fashionable over 5 years ago![]()
This template was created for Joomla 3 many years ago. It is very old and inefficient. Pages like this shouldn't be made anymore - there are too many bells and whistles - it's very heavy and slow.
The best thing about it all is that you used 3 frameworks on this overloaded website: Joomlaart T4, helix-ultimate and sppagebuilder
ALTER TABLE `#__virtuemart_products`
ADD COLUMN `final_price` decimal(15,5) NOT NULL DEFAULT 0 AFTER `product_mpn`;
case 'product_price':
$ff_select_price = ' , p.`final_price` AS product_price ';
$orderBy = ' ORDER BY p.`final_price` ' . $filterOrderDir . ', p.`virtuemart_product_id` ' . $filterOrderDir;
$joinPrice = FALSE;
break;
<?php
define('_JEXEC', 1);
require_once __DIR__ . '/includes/app.php';
$app = Joomla\CMS\Factory::getApplication('site');
if (!class_exists('VmConfig')) {
require(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/config.php');
}
VmConfig::loadConfig();
if (!class_exists('VmModel')) {
require(JPATH_ADMINISTRATOR . '/components/com_virtuemart/helpers/vmmodel.php');
}
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('virtuemart_product_id, product_parent_id')
->from('#__virtuemart_products');
$db->setQuery($query);
$products = $db->loadObjectList();
$productModel = VmModel::getModel('product');
foreach ($products as $prodObj) {
$product_id = (int) $prodObj->virtuemart_product_id;
$product = $productModel->getProduct($product_id, true, true, true);
if (!$product) {
continue;
}
$prices = $productModel->getPrice($product, [], 1);
$finalPrice = isset($prices['salesPrice']) ? (float)$prices['salesPrice'] : 0;
if (
$finalPrice == 0
&& !empty($prodObj->product_parent_id)
&& (int)$prodObj->product_parent_id > 0
) {
$parentProduct = $productModel->getProduct($prodObj->product_parent_id, true, true, true);
if ($parentProduct) {
$pricesParent = $productModel->getPrice($parentProduct, [], 1);
if (!empty($pricesParent['salesPrice'])) {
$finalPrice = (float) $pricesParent['salesPrice'];
}
}
}
$queryUpdate = $db->getQuery(true)
->update('#__virtuemart_products')
->set('final_price = ' . $finalPrice)
->where('virtuemart_product_id = ' . $product_id);
$db->setQuery($queryUpdate);
$db->execute();
}
ALTER TABLE `#__virtuemart_products` ADD INDEX (`final_price`);
Page created in 0.057 seconds with 11 queries.