Jump to content

how to get id_product_attribute from all the id_attribute(s)


Recommended Posts

  • 3 years later...

I know it's an old post, but as I was not able to find how to do this either, I share with you a small function I wrote. You have to add it in classes/Product.php.

 

This allow you to get the id_product_attribute (which is required by $cart->updateQty, if you only have the product id, and the attribute id.

    public function getIdProductAttribute($id_attribute, $id_product)
    {
        return Db::getInstance()->getValue('
        SELECT psnut_product_attribute_combination.id_product_attribute
        FROM psnut_product_attribute_combination
        INNER JOIN psnut_product_attribute
        ON psnut_product_attribute_combination.id_product_attribute = psnut_product_attribute.id_product_attribute
        WHERE psnut_product_attribute.id_product = '.(int)$id_product.'
        AND psnut_product_attribute_combination.id_attribute = '.(int)$id_attribute);
    }

Then you can use

$cart->updateQty(1, $id_product, $product->getIdProductAttribute($id_attribute ,  $id_product), false);
Link to comment
Share on other sites

  • 1 year later...

this is worked for me

SELECT ps_attribute_group_lang.public_name, ps_attribute_lang.name FROM `ps_attribute` join ps_attribute_group_lang on(ps_attribute_group_lang.id_attribute_group = ps_attribute.id_attribute_group) join ps_attribute_langon (ps_attribute_lang.id_attribute = ps_attribute.id_attribute) join ps_product_attribute_shop on (ps_product_attribute_shop.id_product_attribute = ps_attribute.id_attribute) where ps_attribute.id_attribute = 189

Link to comment
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...