Jump to content

[free] virtual products combination prestashop 1.7.x

Recommended Posts

Hi guys,

Since prestashop 1.5, virtual product combinations have been removed. Searching on the web, I have found a workaround for prestashop 1.5 and 1.6 but nothing for Prestashop 1.7.x .

So here we are to make combinations working on virtual products on Prestashop 1.7.x:

please note: paths with "adminXXXXXX" indicate your admin folder name that differs for each installation, so you will have different numbers and letters instead of X.

This is not a module, follow the installation instructions: 

in file adminXXXXXX\themes\default\js\bundle\product\form.js remove line 179:


replace line 182:

showVariationsSelector.find('input[value="0"]').attr('checked', true);



replace line 236:

if ((showVariationsSelector.find('input:checked').val() === '1' || $('#accordion_combinations tr:not(#loading-attribute)').length > 0) && (typeProduct.val() === '1' || typeProduct.val() === '2')) {


if ((showVariationsSelector.find('input:checked').val() === '1' || $('#accordion_combinations tr:not(#loading-attribute)').length > 0) && (typeProduct.val() === '1' /*|| typeProduct.val() === '2'*/)) {

2. in file adminXXXXXX\themes\default\js\bundle\product\product-combination.js remove line 94,95,96:

if (combinationsList.length > 0) {
	productTypeSelector.prop('disabled', true);

remove line 206:

productTypeSelector.prop('disabled', true);

3. create file adminXXXXXX\override\controllers\admin\AdminProductsController.php and write this into it:

class AdminProductsController extends AdminProductsControllerCore

go to controllers\admin\AdminProductsController.php and copy the whole method processAdd(in my case from line 1707 to 1793) and paste it into line 4 of the previous file, the result will be something like this:

class AdminProductsController extends AdminProductsControllerCore
    public function processAdd()

        //some more code here.....

        return $this->object;

last thing, replace this line:

if (Configuration::get('PS_FORCE_ASM_NEW_PRODUCT') && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') && $this->object->getType() != Product::PTYPE_VIRTUAL) {


if (Configuration::get('PS_FORCE_ASM_NEW_PRODUCT') && Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT') /*&& $this->object->getType() != Product::PTYPE_VIRTUAL*/) {

4. Clear the cache!


Now you have working combinations for virtual products.

If I helped you, feel free to offer me a coffe

tested with Prestashop


Edited by Demacri (see edit history)
  • Like 1

Share this post

Link to post
Share on other sites
  • 1 month later...
  • 1 month later...
  • 3 weeks later...
On 3/31/2021 at 6:57 PM, Blue42534325 said:

When I try this, I can only set one file accross the entire product.

How can you add seperate files for each combination?

I didn't need that but i need to do a custom action if an attribute was selected so i created a module with a hookActionValidateOrder.
In hookActionValidateOrder I check for custom attributes on virtual products bought and i put action that i want to do.
Something like:

public function hookActionValidateOrder($params)
    $context = Context::getContext();
    $order = $params['order'];
    $customer = $params['customer'];

    $products = $order->getProducts();
    $myCustomAttributeId = '19';
    $hasTutorial = false;
    foreach($products as $key => $product) {
        //$combinations = $product->getAttributeCombinations($product['product_attribute_id'],$id_lang);
        $sql = 'SELECT * FROM `ps_product_attribute_combination` where id_product_attribute = '.$product['product_attribute_id'].' and id_attribute = '.$myCustomAttributeId;
        $res = Db::getInstance()->executeS($sql);
        if(count($res) > 0) { //there is a product with attribute $myCustomAttributeId in order
        } else {
            //doNothing(?) or something else

not the best solution but it works great.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More