Jump to content

Custom order


yaayhai

Recommended Posts

My Requirement is to Have the Custom ordering Field which is discdribed Super order, which should display in subcategory page only at Bottom, Where the user must select the Product and corresponding attribute, i have framed the function, and strucked in where i need to use like overriding previous controller or else need to create new module or 

 

for you reference,

 

/*To get Product Name, id & category id */
public function fastor($fastid){
$db = Db::getInstance();
$sql = 'SELECT p.id_product AS id, pl.name, p.id_category_default AS cid FROM '._DB_PREFIX_.'_product p INNER JOIN '._DB_PREFIX_.'product_lang pl ON p.id_product = pl.id_product WHERE pl.id_lang=1 AND pl.id_shop='.$lang.' AND p.id_category_default='.$fastid.'';
    $resu = Db::getInstance()->ExecuteS($sql);
$smarty->assign('array',$resu);
return $this->display(__FILE__, 'footer.tpl');
$rea = $resu[id];
$reb = $resu[name];
$rec = $resu[cid];
return $rea;
return $reb;
return $rec;
}
 
 
/*To get Main category id & Name*/
public function quiccat(){
$db = Db::getInstance();
$att ='SELECT p.id_category, pl.name FROM '._DB_PREFIX_.'_category p INNER JOIN '._DB_PREFIX_.'_category_lang pl ON p.id_category = pl.id_category WHERE pl.id_lang=1 AND pl.id_shop=1 AND p.id_parent=2';
$rescv = Db::getInstance()->ExecuteS($att);
$atta=$att[id_category];
$attb=$att[name];
}
 
/*To get Sub category id & Name of the Selected Main category*/
   public function quicsubcat($hmecat){
$db = Db::getInstance();
$atti ='SELECT p.id_category, pl.name FROM '._DB_PREFIX_.'_category p INNER JOIN '._DB_PREFIX_.'_category_lang pl ON p.id_category = pl.id_category WHERE pl.id_lang=1 AND pl.id_shop=1 AND p.id_parent='.$hmecat.'';
$resv = Db::getInstance()->ExecuteS($atti);
$attia=$att[id_category];
$attia=$att[name];
}
 
 
 
/*To fetch selected Product Attributes*/
public function productAttributeExists($attributes_list, $current_product_attribute = false, Context $context = null, $all_shops = false, $return_id = false)
{
if (!Combination::isFeatureActive())
return false;
if ($context === null)
$context = Context::getContext();
$result = Db::getInstance()->executeS(
'SELECT pac.`id_attribute`, pac.`id_product_attribute`
FROM `'._DB_PREFIX_.'product_attribute` pa
JOIN `'._DB_PREFIX_.'product_attribute_shop` pas ON (pas.id_product_attribute = pa.id_product_attribute)
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON (pac.`id_product_attribute` = pa.`id_product_attribute`)
WHERE 1 '.(!$all_shops ? ' AND pas.id_shop ='.(int)$context->shop->id : '').' AND pa.`id_product` = '.(int)$this->id.
($all_shops ? ' GROUP BY pac.id_attribute, pac.id_product_attribute ' : '')
);
 
/* If something's wrong */
if (!$result || empty($result))
return false;
/* Product attributes simulation */
$product_attributes = array();
foreach ($result as $product_attribute)
$product_attributes[$product_attribute['id_product_attribute']][] = $product_attribute['id_attribute'];
/* Checking product's attribute existence */
foreach ($product_attributes as $key => $product_attribute)
if (count($product_attribute) == count($attributes_list))
{
$diff = false;
for ($i = 0; $diff == false && isset($product_attribute[$i]); $i++)
if (!in_array($product_attribute[$i], $attributes_list) || $key == $current_product_attribute)
$diff = true;
if (!$diff)
{
if ($return_id)
return $key;
return true;
}
}
 
return false;
}
 
 
Suggest Me how to add tpl for this, need to override in Footer.tpl file, 
 
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...