Jump to content

[SOLVED] Multiple feature values to product?


yaniv14

Recommended Posts

Hi,

 

I am trying to save multiple values of features to product.

I have changed featured.tpl to select multiple and modified class/Product.php 'addFeaturesToDB' function to accept array, but for some reason its only saves the last object from the selected objects.

 

Any help will be appreciated.

Edited by yaniv14 (see edit history)
Link to comment
Share on other sites

Latest release.

 

I override Product class with:

 

 

public function addFeaturesToDB($id_feature, $id_value, $cust = 0)

{
if ($cust)
{
$row = array('id_feature' => (int)$id_feature, 'custom' => 1);
Db::getInstance()->insert('feature_value', $row);
$id_value = Db::getInstance()->Insert_ID();
}
$base = array(
 'id_feature' => (int)$id_feature,
 'id_product' => (int)$this->id,
);
$rows = array();
foreach ($id_value as $value) {
if(!empty($value)) {
$rows[] = $base + array('id_feature_value' => $value);
}
}
$row = array('id_feature' => (int)$id_feature, 'id_product' => (int)$this->id, 'id_feature_value' => (int)$id_value);
Db::getInstance()->insert('feature_product', $row);
SpecificPriceRule::applyAllRules(array((int)$this->id));
if ($id_value)
return ($id_value);
}

 

and modified admin/features.tpl to select multiple.

 

I can see that the post is ok with the array but it doesn't saves both values, only the second one.

 

Thanks.

Edited by yaniv14 (see edit history)
Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...

jdanthinne

 

this is the error i get trying to install on 1.6.0.9

 

[PrestaShop] Fatal error in module Module:
Uncaught exception 'ReflectionException' with message 'Class FeatureValueOverrideOriginal_remove552cc5d693331 does not exist' in /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/classes/module/Module.php:2496 Stack trace: #0 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/classes/module/Module.php(2496): ReflectionClass->__construct('FeatureValueOve...') #1 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/classes/module/Module.php(2405): ModuleCore->removeOverride('FeatureValue') #2 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/classes/module/Module.php(284): ModuleCore->uninstallOverrides() #3 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/modules/advancedfeaturesvalues/advancedfeaturesvalues.php(26): ModuleCore->install() #4 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/controllers/admin/AdminModulesController.php(805): AdvancedFeaturesValues->install() #5 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/controllers/admin/AdminModulesController.php(1045): AdminMod

 

 

any help appreciated

  • Like 1
Link to comment
Share on other sites

  • 5 months later...

jdanthinne

 

this is the error i get trying to install on 1.6.0.9

 

[PrestaShop] Fatal error in module Module:

Uncaught exception 'ReflectionException' with message 'Class FeatureValueOverrideOriginal_remove552cc5d693331 does not exist' in /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/classes/module/Module.php:2496 Stack trace: #0 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/classes/module/Module.php(2496): ReflectionClass->__construct('FeatureValueOve...') #1 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/classes/module/Module.php(2405): ModuleCore->removeOverride('FeatureValue') #2 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/classes/module/Module.php(284): ModuleCore->uninstallOverrides() #3 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/modules/advancedfeaturesvalues/advancedfeaturesvalues.php(26): ModuleCore->install() #4 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/controllers/admin/AdminModulesController.php(805): AdvancedFeaturesValues->install() #5 /Applications/XAMPP/xamppfiles/apps/prestashop/htdocs/controllers/admin/AdminModulesController.php(1045): AdminMod

 

 

any help appreciated

That happends when you uninstall and install again.

it didnt work for me too

have to wait

For the problems that give after uninstall:

delete de feature class in /override/classes

adminfeat... in /override/controllers/admin

de directory blocklayered from override/modules

and

delete the class_index.php from cache

Edited by Kyasarin (see edit history)
Link to comment
Share on other sites

  • 11 months later...
  • 1 year later...

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...