Jump to content

Prestashop Product Update Hook Is Not Updating Product Attributes In The Hook Function


anil1590

Recommended Posts

I am using hookActionProductUpdate I am getting all data updated but not attribtues, This is the code inside hook function

public function hookActionProductUpdate($params) {
$prestaObject = new ProductCore($params['id_product'], false, Context::getContext()->language->id);
$arrrs = $prestaObject->getFrontFeatures(1);
}

Everything else is updated but the front features I am getting are the older one. Any IDEA?

I am trying in prestashop 1.6

Hello

I tried this too here is my new function

public function hookActionProductUpdate($params) {
$product = $params['product'];
$arrrs = $product->getFrontFeatures(1);
pr($arrrs);die("No updating :(");
}

 

 

here is stackoverflow link
http://stackoverflow.com/questions/35317819/prestashop-product-update-hook-is-not-updating-product-attributes-in-the-hook-fu

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

  • 8 months later...

Hi, did You resolve this issue , I have the same issue. I have my function like this.

public function hookActionProductAttributeUpdate($params)
    {
		echo "test1";
		die;
		if ($params['id_product_attribute']) {
            $idp = $params['id_product'];
            $ida = $params['id_product_attribute'];
            $api = new LinioApi();
            $pr = new LinioProduct($idp, false, Context::getContext()->language->id);
            $sku = $pr->getSku($ida);
            $xml = simplexml_load_string($api->getProductBySku(array($sku)));
            $api->updateProduct($pr->getXmlDesc($ida));
        }
		/*ob_start();
        p($params);
        $content = ob_get_contents();
        file_put_contents('update-pr.txt', $content, FILE_APPEND);
        ob_end_clean();*/
    }

this my function for xml

 public function getXmlDesc($attribute = null)
    {
        $sku = (!$attribute || !$this->attributes) ? $this->reference : $this->attributes[$attribute]['SellerSku'];
        //$qty = StockAvailable::getQuantityAvailableByProduct($this->id, $attribute);
        $xml = '<?xml version="1.0" encoding="UTF-8" ?><Request><Product>';
        $xml .= $this->getXmlProperty('SellerSku', $sku);
        $xml .= $this->getXmlProperty('Description', $this->description);
        $xml .= '</Product></Request>';
        return $xml;
    }

I use the hook quantity and it works perfectly , but this one I cannot print echo test

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