Jump to content

Poradie príslušenstva


reoxid

Recommended Posts

Zdravím.

 

Je v Preste niekde možnosť zoradenia príslušenstva podľa poradia aké chcem ja?

 

Prehľadal som všetky možné nastavenia, ale nič také som nenašiel.

 

Potreboval by som pri rôznych produktoch nastaviť iné poradie príslušenstva podľa toho, čo je k danému produktu prioritnejšie.

 

 

Vďaka za prípadné rady.

Link to comment
Share on other sites

 Nech sa páči:

 

  public function getAccessories($id_lang, $active = true)
    {
        $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
        SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, p.`upc`,
        i.`id_image`, il.`legend`, t.`rate`, m.`name` as manufacturer_name, cl.`name` AS category_default, DATEDIFF(p.`date_add`, DATE_SUB(NOW(),
        INTERVAL '.(Validate::isUnsignedInt(Configuration::get('PS_NB_DAYS_NEW_PRODUCT')) ? Configuration::get('PS_NB_DAYS_NEW_PRODUCT') : 20).' DAY)) > 0 AS new
        FROM `'._DB_PREFIX_.'accessory`
        LEFT JOIN `'._DB_PREFIX_.'product` p ON p.`id_product` = `id_product_2`
        LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` AND pl.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON (p.`id_category_default` = cl.`id_category` AND cl.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` AND i.`cover` = 1)
        LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` AND il.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (p.`id_manufacturer`= m.`id_manufacturer`)
        LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                                                    AND tr.`id_country` = '.(int)Country::getDefaultCountryId().'
                                                    AND tr.`id_state` = 0)
        LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
        WHERE `id_product_1` = '.(int)($this->id).'
        '.($active ? 'AND p.`active` = 1' : ''));

        if (!$result)
            return false;

        return $this->getProductsProperties($id_lang, $result);
    }

    public static function getAccessoryById($accessoryId)
    {
        return Db::getInstance()->getRow('SELECT `id_product`, `name` FROM `'._DB_PREFIX_.'product_lang` WHERE `id_product` = '.(int)($accessoryId));
    }

    /**
    * Link accessories with product
    *
    * @param array $accessories_id Accessories ids
    */
    public function changeAccessories($accessories_id)
    {
        foreach ($accessories_id as $id_product_2)
            Db::getInstance()->AutoExecute(_DB_PREFIX_.'accessory', array('id_product_1' => (int)($this->id), 'id_product_2' => (int)($id_product_2)), 'INSERT');
    }

    /**
    * Add new feature to product
    */
    public function addFeaturesCustomToDB($id_value, $lang, $cust)
    {
        $row = array('id_feature_value' => (int)($id_value), 'id_lang' => (int)($lang), 'value' => pSQL($cust));
        return Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_value_lang', $row, 'INSERT');
    }

    public function addFeaturesToDB($id_feature, $id_value, $cust = 0)
    {
        if ($cust)
        {
            $row = array('id_feature' => (int)($id_feature), 'custom' => 1);
            Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_value', $row, 'INSERT');
            $id_value = Db::getInstance()->Insert_ID();
        }
        $row = array('id_feature' => (int)($id_feature), 'id_product' => (int)($this->id), 'id_feature_value' => (int)($id_value));
        Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_product', $row, 'INSERT');
        if ($id_value)
            return ($id_value);
    }

    public static function addFeatureProductImport($id_product, $id_feature, $id_feature_value)
    {
        return Db::getInstance()->Execute('
            INSERT INTO `'._DB_PREFIX_.'feature_product` (`id_feature`, `id_product`, `id_feature_value`)
            VALUES ('.(int)($id_feature).', '.(int)($id_product).', '.(int)($id_feature_value).')
            ON DUPLICATE KEY UPDATE `id_feature_value` = '.(int)($id_feature_value)
        );
    }

 

Pre istotu to sem dávam celé

Edited by reoxid (see edit history)
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...