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 / StockUpdatePlugin.php
Last active March 1, 2024 12:15
Plugin for Child products stock status change
<?php
namespace Custom\Es\Plugin;
use Klevu\Search\Model\Product\MagentoProductActionsInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\CatalogInventory\Api\StockRegistryInterface;
use Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable;
use Magento\Store\Model\StoreManagerInterface;
@sandipklevu
sandipklevu / Product.php
Last active January 31, 2024 09:17
\Klevu\Search\Model\Product\Product
<?php
namespace Klevu\Search\Model\Product;
use Klevu\Search\Api\Service\Catalog\Product\GetReviewCountInterface;
use Klevu\Logger\Constants as LoggerConstants;
use Klevu\Search\Api\Service\Catalog\Product\Review\ConvertRatingToStarsInterface;
use Klevu\Search\Api\Service\Catalog\Product\Review\GetAverageRatingInterface;
use Klevu\Search\Helper\Compat as CompatHelper;
use Klevu\Search\Helper\Config as ConfigHelper;
<?php
ini_set('display_errors', 1);
ini_set('memory_limit', -1);
use Klevu\Search\Helper\Config;
use Klevu\Search\Model\Product\LoadAttributeInterface;
use Klevu\Search\Model\Product\ProductInterface;
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\ObjectManager;
use Klevu\Search\Helper\Stock as KlevuStockHelper;
@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();
@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 / 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 / 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 / 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 / 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 / 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>