Example #1
0
    /**
     * Fires when the user click on "Import buyer protection articles" button in the plugin config
     * @return void
     */
    public function testConnectionAction()
    {
        //access to the plugin configuration
        $config = Shopware()->Plugins()->Frontend()->SwagTrustedShopsExcellence()->Config();
        $message = "";

        //to import the trusted shop articles the trusted shop id must given
        if(empty($config->tsEID)) {
            $message .= $this->createMessageTag("- Es wurde keine Trusted Shop ID hinterlegt");
        }
        if(empty($config->tsWebServiceUser)) {
            $message .= $this->createMessageTag(" - Es wurde keine Trusted Shop Web Service User hinterlegt");
        }
        if(empty($config->tsWebServicePassword)) {
            $message .= $this->createMessageTag(" - Es wurde kein Trusted Shop Web Service Passwort hinterlegt");
        }

        //check login
        $loginParams = array("tsId" => $config["id"], "wsUser" => $config["user"], "wsPassword" => $config["pw"]);
        $tsDataModel = new TrustedShopsDataModel();

        if(!$tsDataModel->checkLogin($loginParams)) {
            $message .= $this->createMessageTag(" - Der Login bei Trusted Shop war nicht erfolgreich. Bitte überprüfen Sie Ihre Zugangsdaten.");
        }

        if(!empty($message)) {
            $this->View()->assign(array('success' => true, 'message' => $message));
            return;
        }

        $validCertifications = array("EXCELLENCE", "PRODUCTION", "INTEGRATION", "TEST");
        $tsDataModel = new TrustedShopsDataModel();
        $certificated = $tsDataModel->checkCertificate();

        if(!in_array($certificated->stateEnum, $validCertifications)) {
            $message .= $this->createMessageTag(" - Ihr Trusted Shops Zertifikat ist nicht gültig.");
        }

        if(empty($message)) {
            $message .= $this->createMessageTag("- Die Verbindung konnte erfolgreich aufgebaut werden.");
        }

        $this->View()->assign(array('success' => true, 'message' => $message));
    }
Example #2
0
	/**
	 * This function updated and download the trusted shop rating image.
	 * @return string | image data
	 */
	public function importTsRatingImage()
	{
		$config = $this->getTrustedShopBasicConfig();

		$tsDataModel = new TrustedShopsDataModel();
		$params = array("tsId" => $config["id"], "activation" => 1, "wsUser" => $config["user"], "wsPassword" => $config["pw"], "partnerPackage" => "");
		$tsDataModel->updateRatingWidgetState($params);

		$imagePath = Shopware()->DocPath() . 'images/ts_rating.gif';
		$image = file_get_contents("https://www.trustedshops.com/bewertung/widget/widgets/" . $config["id"] . ".gif");
		file_put_contents($imagePath, $image);
		return $image;
	}