Open navigation

Magento image indexing problems (eg. /needtochange/)

While indexing the images, Klevu put the “needtochange” in the URL. The reason is on the frontend, Klevu checks for the Magento setup i.e. the domain is pointed to the pub directory or at the Magento root.
If the Magento is pointed to Magento root, Klevu changes the image URL to replace “needtochange” to “pub”. While, if the Magento is pointed to the Pub directory, Klevu changes the image URL to replace “need to change” to “” (blank).

Below is the frontend Script to handle above scenario:

 <script type="text/javascript">
    klevu_pubIsInUse = false/true ;
    if(!(typeof klevu_uc_productCustomizations === "function" && typeof klevu_uc_productCustomizations.nodeType !== "number"))
        function klevu_uc_productCustomizations( product ){
            if(klevu_pubIsInUse){
                product.productImage = product.productImage.replace( 'pub/', '');
                product.productImage = product.productImage.replace( 'needtochange/', '');
            } else {
                product.productImage = product.productImage.replace( 'needtochange/', 'pub/');
            }
            
            if ('undefined' !== typeof klevuMagentoCustomerGroupFlag && klevuMagentoCustomerGroupFlag == false) {
                product.productPrice = '0';
                product.startPrice = '0';
                product.toPrice = '0';
                product.salePrice = '0';
            }

            return product;
        }
    }
</script>

If the klevu_pubIsInUse variable is being set up as “false” then “needtochange” would be replaced with “pub” and if the klevu_pubIsInUse variable is “true” then “needtochange” would be replaced with “”(blank).

Klevu uses the below PHP code to fetch this information:

klevu_pubIsInUse = isPubInUse())?”true”:”false”; ?> ; (in file)

Where isPubInUse is defined in the class.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.