Answer the question
In order to leave comments, you need to log in
For the life of me, I can’t find the error, where did she hide?
I send the ID to the server with Ajax, I output the result to the console.
In the controller
public function actionAdd()
{
if (Yii::$app->request->isAjax && Yii::$app->request->isGet)
{
$id = Yii::$app->request->get('id');
$product = Notebooks::findOne($id);
if(empty($product))
{
return false;
}
else
{
$session = Yii::$app->session;
$session->open();
$compare = new Compare();
$compare->addToCompare($product);
}
}
}
namespace app\models;
use yii\db\ActiveRecord;
class Compare extends ActiveRecord
{
public function addToCompare($product, $qty = 1)
{
return 'работайпсина';
}
}
echo 'работайпсина';
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question