Giter Club home page Giter Club logo

magento2doc's Introduction

Guia de desenvolvimento e boas práticas em Magento 2

Guia de desenvolvimento e boas práticas em Magento 2 (em desenvolvimento, desconsidere qualquer erro de formatação e conteúdo fora de organização)

Todo o conteúdo está disponível em nossa Wiki

Assim como todo youtuber pede pra você dar aquele joinha no vídeo, dê uma estrelinha nesse repositório :)

Se você gostou e quer contribuir, não deixe de ler as Diretrizes de contribuição para este projeto

Caso queira saber sobre um assunto que ainda não foi publicado veja Como fazer sugestões de conteúdo

Aproveite e marque com uma estrela esse repositório. Vamos chegar a 10000?

magento2doc's People

Contributors

thiagolima-bm avatar

Stargazers

Leonardo Crestani avatar  avatar Bruno T. Araujo avatar Alenilson Souza avatar Fabrício Valle avatar  avatar lalit mohan avatar Michel Brito avatar Maico da Silva avatar Eduardo avatar  avatar Tiago Batista avatar  avatar Douglas Maia avatar Fernando Macedo avatar Diego Perico avatar Álvaro Gomides avatar Rafael Corrêa Gomes avatar Edilson Cichon avatar Jonatan Machado avatar Denis Colli Spalenza avatar  avatar adrielera avatar Humberto Leite avatar Mateus Souza avatar Fernando Fauth avatar Mauro Silva avatar Bruno Roeder avatar Alexandre Thurow avatar Max Souza avatar Carlos Augusto Gartner avatar Rafael Patro avatar OntheFrontLine avatar Mage avatar

Watchers

Fernando Macedo avatar Leandro avatar James Cloos avatar Eder Silva avatar  avatar Rafael Patro avatar OntheFrontLine avatar

magento2doc's Issues

Instalação Composer x Manual

Olá, parabéns pela iniciativa!
Estava lendo a wiki/instalação e eu estou usando o instalador do magento, tem alguma diferença além da velocidade de instalação?

Shipping Method - Adicionar novo Courier com requisição API

Olá, gostaria de uma ajuda se possível, estou tentando criar um módulo para calcular o preço do frete, mas não tem nenhum tutorial na internet que ensine fazer requisições com api, olhei o módulo da ups e dhl, porém não consegui definir a lógica.

Model.php

<?php
namespace Kauan\Shipping\Model\Carrier;

use Magento\Quote\Model\Quote\Address\RateRequest;
use Magento\Shipping\Model\Rate\Result;
use Magento\Quote\Model\Quote\Address\RateResult\Error;
use Magento\Shipping\Model\Carrier\AbstractCarrierOnline;
use Magento\Shipping\Model\Carrier\CarrierInterface;
use Magento\Shipping\Model\Simplexml\Element;
use Magento\Ups\Helper\Config;
use Magento\Framework\Xml\Security;

class Datafrete extends \Magento\Shipping\Model\Carrier\AbstractCarrier implements
    \Magento\Shipping\Model\Carrier\CarrierInterface
{
    /**
     * @var string
     */
    protected $_code = 'shipping';

    /**
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
     * @param \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory
     * @param \Psr\Log\LoggerInterface $logger
     * @param \Magento\Shipping\Model\Rate\ResultFactory $rateResultFactory
     * @param \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory
     * @param array $data
     */
    public function __construct(
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
        \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory,
        \Psr\Log\LoggerInterface $logger,
        Security $xmlSecurity,
        \Magento\Shipping\Model\Simplexml\ElementFactory $xmlElFactory,
        \Magento\Shipping\Model\Rate\ResultFactory $rateFactory,
        \Magento\Quote\Model\Quote\Address\RateResult\MethodFactory $rateMethodFactory,
        \Magento\Shipping\Model\Tracking\ResultFactory $trackFactory,
        \Magento\Shipping\Model\Tracking\Result\ErrorFactory $trackErrorFactory,
        \Magento\Shipping\Model\Tracking\Result\StatusFactory $trackStatusFactory,
        \Magento\Directory\Model\RegionFactory $regionFactory,
        \Magento\Directory\Model\CountryFactory $countryFactory,
        \Magento\Directory\Model\CurrencyFactory $currencyFactory,
        \Magento\Directory\Helper\Data $directoryData,
        \Magento\CatalogInventory\Api\StockRegistryInterface $stockRegistry,
        \Magento\Framework\Locale\FormatInterface $localeFormat,
        Config $configHelper,
        array $data = []
    ) {
        $this->_rateResultFactory = $rateResultFactory;
        $this->_rateMethodFactory = $rateMethodFactory;
        parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
    }

    /**
     * @return array
     */
    public function getAllowedMethods()
    {
        return ['datafrete' => $this->getConfigData('name')];
    }

    /**
     * @param RateRequest $request
     * @return bool|Result
     */



    public function collectRates(RateRequest $request)
    {
        if (!$this->getConfigFlag('active')) {
            return false;
        }
        //API CONNECTION
        $options = array('location' => $this->getConfigData('api'),
                                    'uri'      => $this->getConfigData('api').'?wsdl');

         $client = new SoapClient($this->url_integracao."?wsdl",$options);

         //ITS OK TO GET INFOS PRODUCTS LIKE THIS? 
        $itemsShipment = $request->getPackageItems();
        foreach ($itemsShipment as $itemShipment) {
            $item = new \Magento\Framework\DataObject();
            $item->setData($itemShipment);
            $nome = $item->getName();
            $preco =  $item->getPrice();
        }


 //FUNCTION TO GET INFO/VALUES FROM API - RETURN A JSON
             $consulta_frete = $client->getValorFrete(
//NEED KNOW IF THIS LIST CONTAINS RIGHT INFOS TO POST ON API                                                                    $this->getConfigData('usuario'),
                                                                    $this->getConfigData('senha'),
                                                                    $this->getConfigData('codigo'),
                                                                $request->getOrigPostcode(),
                                                                $request->getDestPostcode(),
                                                                $json_produto,
                                                                $json_inf_comp);

        $consulta_frete = json_decode($consulta_frete);


//HOW I USE FOREACH TO DECLARE VALUES AND DESCRIPTIONS ON METHOD->SETPRICE

        /** @var \Magento\Shipping\Model\Rate\Result $result */
        $result = $this->_rateResultFactory->create();

        /** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */
        $method = $this->_rateMethodFactory->create();

        $method->setCarrier('datafrete');
        $method->setCarrierTitle($this->getConfigData('title'));

        $method->setMethod('datafrete');
        $method->setMethodTitle($this->getConfigData('name'));

        /*you can fetch shipping price from different sources over some APIs, we used price from config.xml - xml node price*/
        //$amount = $this->getConfigData('price');

        $method->setPrice($amount);
        $method->setCost($amount);

        $result->append($method);

        return $result;
    }
}

Não sei como pegar as informações do carrinho, enviar para api e retornar os valores para o carrinho.

Abraço.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.