Skip to content

Instantly share code, notes, and snippets.

View sandipklevu's full-sized avatar
🎯
Focusing

Sandip Chandela sandipklevu

🎯
Focusing
View GitHub Profile
@sandipklevu
sandipklevu / ksearch-catnav.js
Last active June 10, 2021 09:25
SFCC - int_klevu_sfra/cartridge/static/default/js/ksearch-catnav.js
var klevu_pageCategory = document.getElementById("klevuCategoryPath").value;
sessionStorage.setItem("klevu_pageCategory", klevu_pageCategory.trim());
@sandipklevu
sandipklevu / magento-directUpdateRecordsToKlevu.php
Created November 23, 2022 05:35
To update product directly to Klevu Indexer
<?php
/**
* From terminal, run as follows
* php magento-directUpdateRecordsToKlevu.php <store_id>
* store_id will be 1 by default, store_id is an optional parameter
* Direct script to update the product to Klevu indexer.
* Use this script wisely as this script will not check whether given product needs to add or update or delete etc.
*
* NOTE: Recommend to use only for troubleshooting.
*/
@sandipklevu
sandipklevu / klevu-sync-debug
Last active April 28, 2023 12:24
Gist for Klevu module 3.2.1 to trouble shoot debug issue
#!/usr/bin/env php
<?php
use Klevu\Search\Api\KlevuSyncRepositoryInterface;
use Klevu\Search\Api\MagentoProductSyncRepositoryInterface;
use Klevu\Search\Model\Klevu\Klevu;
use Magento\Eav\Model\Entity;
use Magento\Framework\App\Bootstrap;
use Magento\Store\Api\Data\StoreInterface;
@sandipklevu
sandipklevu / search.xml
Created June 5, 2023 12:53
<magento-root>/app/design/frontend/rwd/default/layout/klevu/search.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="head">
<block type="core/template"
name="klevu.search.v2.js.init"
template="klevu/search/v2/js-init.phtml"/>
</reference>
</default>
<catalog_product_view>
@sandipklevu
sandipklevu / content.xml
Created June 5, 2023 12:55
<magento-root>/app/design/frontend/rwd/default/layout/klevu/content.xml
<?xml version="1.0"?>
<layout version="0.1.0">
<content_search_index>
<reference name="root">
<action method="setTemplate">
<template>page/2columns-left.phtml</template>
</action>
</reference>
<reference name="head">
<!-- Remove Deprecated JSv1 Stylesheet to avoid conflict -->
@sandipklevu
sandipklevu / js-init.phtml
Created June 5, 2023 12:56
<magento-root>/app/design/frontend/rwd/default/template/klevu/search/v2/js-init.phtml For e.g. `rwd/default` is a active theme
<?php
/** @var Mage_Core_Block_Template $this */
/** @var Klevu_Search_Helper_Config $config */
/** @var Klevu_Search_Helper_Data $helper */
?>
<?php $config = Mage::helper('klevu_search/config'); ?>
<?php $helper = Mage::helper('klevu_search'); ?>
<?php if ($config->isExtensionConfigured()): ?>
<?php $urlRoute = 'catalogsearch/result/'; ?>
<?php if ($config->isLandingEnabled() === 2): ?>
@sandipklevu
sandipklevu / search.phtml
Created June 5, 2023 12:59
<magento-root>/app/design/frontend/rwd/default/template/klevu/search/v2/search.phtml For e.g. `rwd/default` is a active theme
<script src="https://js.klevu.com/theme/default/v2/search-results-page.js"></script>
<div class="klevuLanding"></div>
@sandipklevu
sandipklevu / contentAssetsUtils.js
Created July 10, 2023 13:29
bm_klevu/cartridge/scripts/jobs/export/klevuContentAssetsExport.js
/* bm_klevu/cartridge/scripts/utils/contentAssetsUtils.js */
'use strict';
/* API Includes*/
const File = require('dw/io/File');
const FileWriter = require('dw/io/FileWriter');
const FileReader = require('dw/io/FileReader');
const XMLIndentingStreamWriter = require('dw/io/XMLIndentingStreamWriter');
const XMLStreamReader = require('dw/io/XMLStreamReader');
const XMLStreamConstants = require('dw/io/XMLStreamConstants');
@sandipklevu
sandipklevu / klevu-sales-tracking.php
Last active September 29, 2023 05:43
Can place this script on `pub` folder
<?php
use Klevu\Search\Model\System\Config\Source\Order\Ip as OrderIP;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Exception\NoSuchEntityException;
if (PHP_SAPI !== 'cli') {
echo 'klevu-sales-tracking must be run as a CLI application';
exit(1);
@sandipklevu
sandipklevu / remove-m2-mview.php
Created October 16, 2023 10:29
Magento 2 mview remove subscription if not being used
<?php
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/../app/bootstrap.php';
$params = $_SERVER;
$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();