Skip to content

Instantly share code, notes, and snippets.

View blopa's full-sized avatar
🏴‍☠️

Pablo Benmaman blopa

🏴‍☠️
View GitHub Profile
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-17.sh
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
bin/magento module:enable Werules_GameShop
bin/magento setup:upgrade
bin/magento cache:flush
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-16.php
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<?php
$mediaUrl = $block->getViewFileUrl('Werules_GameShop::images/shopkeeper.png');
$baseUrl = $block->getBaseUrl();
$pageTitle = __('GameShop - Buy & Sell Games');
$pageDescription = __('Find the best gaming deals, buy and sell games easily!');
?>
<!-- Open Graph Meta Tags -->
<meta property="og:image" content="<?= $mediaUrl ?>"/>
<meta property="og:image:alt" content="GameShop Shopkeeper Avatar"/>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-15.xml
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<referenceBlock name="head.additional">
<block class="Magento\Framework\View\Element\Template"
name="werules.gameshop.head"
template="Werules_GameShop::seo/head.phtml"/>
</referenceBlock>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-14.js
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
methods: {
onMenuItemClick(selection) {
if (selection === 'Talk') {
const randomIndex = Math.floor(Math.random() * this.talkLines.length);
this.currentTalkLine = this.talkLines[randomIndex];
}
}
}
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-13.html
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<div v-else-if="menuSelection === 'Talk'" class="flex items-center justify-center h-64 border-2 border-orange-500 p-6">
<p class="text-3xl text-orange-400 text-center">
{{ currentTalkLine }}
</p>
</div>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-12.html
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<div v-if="activeView === 'detail' && currentProduct" class="space-y-4">
<p class="italic text-lg mb-2">
<?= sprintf(__('Ah, the %s! This item might do something special...'), '<strong>{{ currentProduct.name }}</strong>'); ?>
</p>
<div class="flex flex-col md:flex-row space-y-4 items-start border border-orange-500 p-4">
<img :src="currentProduct.image_url"
class="w-72 h-72 object-cover border border-orange-500 bg-black">
<div class="flex-1">
<h3 class="text-2xl font-bold">{{ currentProduct.name }}</h3>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-11.html
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<div v-if="activeView === 'list'">
<div v-if="products.length === 0" class="text-center text-orange-400 text-lg mt-6">
<?= __('No products found in this category.'); ?>
</div>
<div class="space-y-3">
<div v-for="product in products" :key="product.id"
class="border border-orange-500 p-4 flex flex-col md:flex-row items-center cursor-pointer hover:bg-orange-900 transition"
@click="showDetails(product)">
<img :src="product.image_url"
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-10.html
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<!-- Category Tabs -->
<div v-if="activeView === 'list'" class="flex flex-wrap gap-2 mb-3">
<button v-for="cat in categories" :key="cat.id"
class="px-3 py-1 border border-orange-500 hover:bg-orange-500 hover:text-black transition"
:class="{'bg-orange-500 text-black': currentCategoryId === cat.id}"
@click="loadProducts(cat.id, cat.name)">
{{ cat.name }}
</button>
</div>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-9.html
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<button class="block w-full py-3 border border-orange-500 hover:bg-orange-900 text-center px-4 text-lg"
:class="{'bg-orange-500 text-black': menuSelection === 'Buy'}"
@click="onMenuItemClick('Buy')">
<?= __('Buy'); ?>
</button>
<button class="block w-full py-3 border border-orange-500 hover:bg-orange-900 text-center px-4 text-lg"
:class="{'bg-orange-500 text-black': menuSelection === 'Sell'}"
@click="onMenuItemClick('Sell')">
<?= __('Sell'); ?>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-8.html
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<!-- Shopkeeper Avatar -->
<div class="border-2 border-orange-500 p-2 flex justify-center items-center bg-black">
<img src="<?= $block->getViewFileUrl('Werules_GameShop::images/shopkeeper.png'); ?>"
alt="<?= __('Shopkeeper Avatar'); ?>"
class="w-32 h-32 object-cover border border-orange-500 bg-black avatar">
</div>
<!-- Cart Count -->
<div class="mb-4">
<div class="text-lg text-orange-400"><?= __('Cart items:'); ?></div>