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-7.html
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<div class="border-2 border-orange-500 p-3 sticky top-0 bg-black z-50">
<h1 class="text-3xl md:text-4xl font-bold tracking-widest uppercase">
<?php echo $currentStoreName; ?>
</h1>
</div>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-6.html
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<div id="app" class="min-h-screen bg-black text-orange-200 font-mono p-6 flex flex-col space-y-4 text-lg">
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-5.php
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
public function getProductsByCategoryId($categoryId)
{
if (!$this->isModuleEnabled()) {
return [];
}
// Standard product retrieval logic
}
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-4.php
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
public function getCartItemCount()
{
if (!$this->isModuleEnabled()) {
return 0;
}
$quote = $this->cart->getQuote();
return (int)$quote->getItemsQty();
}
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-3.php
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<?php
namespace Werules\GameShop\Controller\Index;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\Controller\ResultFactory;
use Magento\Framework\App\Config\ScopeConfigInterface;
class Index extends Action
{
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-2.xml
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route id="werules_gameshop" frontName="game-shop">
<module name="Werules_GameShop"/>
</route>
</router>
</config>
@blopa
blopa / i-built-a-retro-rpg-game-shop-extension-for-my-magento-2-store-script-1.text
Created February 2, 2025 18:47
Code for post "I built a retro RPG game shop extension for my Magento 2 store"
app/code/Werules/GameShop/
├── Api/
│ ├── CartManagementInterface.php
│ ├── CategoryManagementInterface.php
│ ├── ProductManagementInterface.php
├── Controller/
│ ├── Index/
│ │ ├── Index.php
├── etc/
│ ├── adminhtml/
@blopa
blopa / criando-uma-extensão-magento-2-para-automatizar-a-descrição-de-produtos-script-4.php
Created February 2, 2025 11:21
Code for post "Criando uma extensão Magento 2 para automatizar a descrição de produtos"
private function generateDescriptionFromGemini($prompt, $apiKey)
{
$ch = curl_init("https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateText?key={$apiKey}");
$data = ['contents' => [['parts' => [['text' => $prompt]]]]];
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
@blopa
blopa / criando-uma-extensão-magento-2-para-automatizar-a-descrição-de-produtos-script-3.javascript
Created February 2, 2025 11:21
Code for post "Criando uma extensão Magento 2 para automatizar a descrição de produtos"
require(['jquery'], function ($) {
window.fetchAutofillData = function () {
var productId = '<?= $productId ?>';
var productName = $('[name="product[name]"]').val() || 'N/A';
var productPrice = $('[name="product[price]"]').val() || 'N/A';
$.ajax({
url: '<?= $ajaxUrl ?>',
type: 'POST',
data: { product_id: productId, product_name: productName, product_price: productPrice },
@blopa
blopa / criando-uma-extensão-magento-2-para-automatizar-a-descrição-de-produtos-script-2.xml
Created February 2, 2025 11:21
Code for post "Criando uma extensão Magento 2 para automatizar a descrição de produtos"
<field id="api_provider" translate="label" type="select" sortOrder="6" showInDefault="1">
<label>AI Provider</label>
<source_model>Werules\Autofill\Model\Config\Source\ApiProvider</source_model>
</field>
<field id="api_key" type="text" sortOrder="10">
<label>OpenAI API Key</label>
</field>
<field id="gemini_api_key" type="text" sortOrder="15">
<label>Gemini API Key</label>
</field>