Skip to content

Instantly share code, notes, and snippets.

View yogeshdubey2006's full-sized avatar
🏠
Working from home

Yogesh Dubey yogeshdubey2006

🏠
Working from home
View GitHub Profile
@yogeshdubey2006
yogeshdubey2006 / catalog_product_view.xml
Created June 2, 2019 10:07
Magento 2 - Get product review list on product page
<page layout="2columns-right" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceContainer name="content">
<block class="Magento\Review\Block\Product\Review" name="reviews.tab" as="reviews" template="Magento_Review::review.phtml" group="detailed_info">
<block class="Magento\Review\Block\Product\View\ListView" name="product.info.product_additional_data" as="product_additional_data" template="product/view/list.phtml"/>
<block class="Magento\Theme\Block\Html\Pager" name="product_review_list.toolbar"/>
<block class="Magento\Review\Block\Form" name="product.review.form" as="review_form">
<container name="product.review.form.fields.before" as="form_fields_before" label="Review Form Fields Before"/>
</block>
</block>
@yogeshdubey2006
yogeshdubey2006 / important-module-urls.php
Created May 18, 2019 13:07
Magento 2.1.1 Invalid input date format 'Invalid date'
<?php
# follow below url to fix date format issue on catalog product page
# https://github.com/fernandofauth/magento2_datetime
#
#
@yogeshdubey2006
yogeshdubey2006 / functions.php
Created March 27, 2019 10:24
WordPress - Developer plugin to echo template names/filepaths
<?php
# Here is what I use. It will display the current template file name to logged-in users. Paste this in your functions.php file and comment out/remove when not in use.
// REMOVE - show template name
add_action('wp_head', 'show_template');
function show_template() {
global $template;
global $current_user;
get_currentuserinfo();
if ($current_user->user_level == 10 ) print_r($template);
@yogeshdubey2006
yogeshdubey2006 / magento_removeAllCategories.sql
Created March 27, 2019 09:34
Magento - Remove all categories from a store
# Worked a treat on Magento 1.9, Backup first.
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_category_entity`;
TRUNCATE TABLE `catalog_category_entity_datetime`;
TRUNCATE TABLE `catalog_category_entity_decimal`;
TRUNCATE TABLE `catalog_category_entity_int`;
TRUNCATE TABLE `catalog_category_entity_text`;
TRUNCATE TABLE `catalog_category_entity_varchar`;
TRUNCATE TABLE `catalog_category_product`;
@yogeshdubey2006
yogeshdubey2006 / truncate_url_rewrites.sql
Created March 27, 2019 09:31
Magento - Truncate URL Rewrites
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `core_url_rewrite`;
TRUNCATE TABLE `enterprise_catalog_category_rewrite`;
TRUNCATE TABLE `enterprise_catalog_product_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite_category_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_product_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect_cl`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect_rewrite`;
TRUNCATE TABLE `enterprise_url_rewrite_redirect`;
@yogeshdubey2006
yogeshdubey2006 / head.phtml
Created March 27, 2019 09:28
Magento - Twitter & facebook meta cards
<?php
<meta http-equiv="Content-Type" content="<?php echo $this->getContentType() ?>" />
<title><?php echo $this->getTitle() ?></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<?php
if (Mage::registry('current_product')) {
$current_product = Mage::registry('current_product');
$desc = preg_replace('/\s+?(\S+)?$/', '', substr(strip_tags(str_replace(array("\r\n", "\r", "\n"), "", $this->getDescription())), 0, 150));
@yogeshdubey2006
yogeshdubey2006 / view.phtml
Created March 27, 2019 09:23
Magento 2 - Get category name for current product.
<?php
# To get the category name of current product in magento add this code to any phtml file related to product view page like add to cart, add to, gallery page and paste this code.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->get('Magento\Framework\Registry')->registry('current_product');
$categories = $product->getCategoryIds(); /*will return category ids array*/
foreach($categories as $category){
$cat = $objectManager->create('Magento\Catalog\Model\Category')->load($category);
echo $cat->getName();
}
?>
@yogeshdubey2006
yogeshdubey2006 / index.txt
Created March 27, 2019 09:22
CSS - hover effects
https://tympanus.net/Development/HoverEffectIdeas/
https://tympanus.net/Development/HoverEffectIdeas/index2.html
@yogeshdubey2006
yogeshdubey2006 / instruction.txt
Created March 27, 2019 06:53
Magento 2- Add animation to sections on scroll and Preloader
<!-- AOS -->
Step 1: follow: https://michalsnik.github.io/aos/
Step 2: Add
<link href="https://unpkg.com/[email protected]/dist/aos.css" rel="stylesheet">
<script src="https://unpkg.com/[email protected]/dist/aos.js"></script>
Step 3: add jquery dependency (requirejs-config.js)
var config = {
shim: {
jquery: {
@yogeshdubey2006
yogeshdubey2006 / hide-account-menu.links.css
Created March 18, 2019 11:12
Magento 2 - hide account or menu tabs in mobile version.