Jump to content

Block specials / display product attributes


Recommended Posts

OK i made it wirh a little help od this forum posts history! :)

 

add to blockspecials.php this code:

public function getProductAttributeCombinations($products) {
        $combinations = array();
    
        foreach($products as $product)
        {
            // load product object
            $product = new Product ($product['id_product'], $this->context->language->id);
    
            // get the product combinations data
            // create array combinations with key = id_product
            $combinations[$product->id] = $product->getAttributeCombinations($this->context->language->id);
        }
    
        return $combinations;
    }

    public function hookRightColumn($params)
{
    if (Configuration::get('PS_CATALOG_MODE'))
        return;
 
    // We need to create multiple caches because the products are sorted randomly
    $random = date('Ymd').'|'.round(rand(1, max(Configuration::get('BLOCKSPECIALS_NB_CACHES'), 1)));
 
    if (!Configuration::get('BLOCKSPECIALS_NB_CACHES') || !$this->isCached('blockspecials.tpl', $this->getCacheId('blockspecials|'.$random)))
    {
        if (!($specials = Product::getPricesDrop((int)$params['cookie']->id_lang, 0, 5)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
            return;
            
        $produkty = Product::getPricesDrop((int)$params['cookie']->id_lang, 0, 5);
        $combinations = $this->getProductAttributeCombinations($produkty);
        
 
        $this->smarty->assign(array(
            'specials' => $specials,
            'combinations' => $combinations,
            'mediumSize' => Image::getSize(ImageType::getFormatedName('medium')),
        ));
 
    }

and in theme

{foreach from=$combinations key=k item=comb}
                                    {if $k == $special.id_product}

                                                    {$attr.attribute_name}
                                        
                                    {/if}
                                {/foreach}
Edited by saracoratello (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...