Jump to content

langziyang

Members
  • Posts

    85
  • Joined

  • Last visited

About langziyang

  • Birthday 12/28/1982

Contact Methods

Profile Information

  • Location
    China
  • Activity
    Module Developer

Recent Profile Visitors

5,741,556 profile views

langziyang's Achievements

Rookie

Rookie (2/14)

  • Conversation Starter Rare
  • Week One Done Rare
  • One Month Later Rare
  • One Year In Rare

Recent Badges

2

Reputation

  1. hi,i have new service on my module:mymodule/src/Services/ProductDataProviderService.php i want override src/Adapter/Product/ProductDataProvider.php some function, so i use https://devdocs.prestashop.com/1.7/modules/concepts/services/#decorate-the-service and i am Chinese,i use google translate the doc,i am not sure i really understand the doc. mymodule/config/services.yml services: jinber.etproductgif.prestashop.adapter.data_provider.product: class: Jinber\ProductGif\Services\ProductDataProviderService decorates: 'prestashop.adapter.data_provider.product' arguments: [ '@jinber.etproductgif.prestashop.adapter.data_provider.product.inner' ] public: false mymodule/src/Services/ProductDataProviderService.php <?php namespace Jinber\ProductGif\Services; class ProductDataProviderService { public function getImage($id_image) { $imageData = new \Image((int)$id_image); return [ 'id' => $imageData->id, 'id_product' => $imageData->id_product, 'position' => $imageData->position, 'cover' => $imageData->cover ? true : false, 'legend' => $imageData->legend, 'format' => 'gif', 'base_image_url' => _THEME_PROD_DIR_ . $imageData->getImgPath(), ]; } } when i refresh page, i get UndefinedMethodException: Attempted to call an undefined method named "getProduct" of class "Jinber\ProductGif\Services\ProductDataProviderService". so i extends the PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider, now my code like this: <?php namespace Jinber\ProductGif\Services; use PrestaShop\PrestaShop\Adapter\Product\ProductDataProvider; class ProductDataProviderService extends ProductDataProvider { public function getImage($id_image) { $imageData = new \Image((int)$id_image); return [ 'id' => $imageData->id, 'id_product' => $imageData->id_product, 'position' => $imageData->position, 'cover' => $imageData->cover ? true : false, 'legend' => $imageData->legend, 'format' => 'gif', 'base_image_url' => _THEME_PROD_DIR_ . $imageData->getImgPath(), ]; } } now it`s working. so i want know extends ProductDataProvider is correct right?
  2. Firstly,i use https://validator.prestashop.com/generator generate new module,name "mymodule" then,i use compoer init to generate composer json like this: { "name": "jinber/mymodule", "autoload": { "psr-4": { "Jinber\\Mymodule\\": "src/" }, "classmap": [ "mymodule.php", "controllers/", "classes/" ] }, "require": {}, "config": { "preferred-install": "dist", "classmap-authoritative": true, "optimize-autoloader": true, "prepend-autoloader": false } } next i use composer require wechatpay/wechatpay to install this sdk now,my vendor like this: this sdk use guzzlehttp 7+ when i follow sdk doc created some code, i got error: AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Error: Call to undefined method GuzzleHttp\\Utils::chooseHandler() in /www/wwwroot/p.shoucangjie.xin/modules/mymodule/vendor/guzzlehttp/guzzle/src/HandlerStack.php:49\nStack trace:\n#0 /www/wwwroot/p.shoucangjie.xin/modules/mymodule/vendor/wechatpay/wechatpay/src/ClientXmlTrait.php(123): GuzzleHttp\\HandlerStack::create()\n#1 /www/wwwroot/p.shoucangjie.xin/modules/mymodule/vendor/wechatpay/wechatpay/src/ClientDecorator.php(103): WeChatPay\\ClientDecorator::xmlBased()\n#2 /www/wwwroot/p.shoucangjie.xin/modules/mymodule/vendor/wechatpay/wechatpay/src/Builder.php(43): WeChatPay\\ClientDecorator->__construct()\n#3 /www/wwwroot/p.shoucangjie.xin/modules/mymodule/classes/WePayServer.php(9): WeChatPay\\Builder::factory()\n#4 /www/wwwroot/p.shoucangjie.xin/modules/mymodule/mymodule.php(244): WePayServer->jsapiPay()\n#5 /www/wwwroot/p.shoucangjie.xin/modules/mymodule/controllers/front/jsapi.php(12): Etrestapi->getPayInfo()\n#6 /www/wwwroot/p.shoucangjie.xin/classes/contro...', referer: https://servicewechat.com/wx8bf53686614eb4e6/devtools/page-frame.html no matter include vendor/autoload.php or not and run composer dump-autoload on modules/mymodule/ . always show this error note: this sdk in symfony project work fine and chooseHandler function exists
  3. http://www.domain.com/api/product/?ws_key=VQ53VDUZLEDMHW444911GHDJWA4WBNYG&language=1&output_format=JSON&display=full&id_category=3&attribute=3 i can use this like to filter product,but if i have two and more attribute or id_category,how get it?
  4. this module can update image to CDN, your server only need one origin image. no need resize other small image. https://github.com/langziyang/etcloudimage
  5. https://devdocs.prestashop.com/1.7/modules/concepts/forms/admin-forms/ this doc is add new field to admin configuation but if i want add other options to caching type like: Memcache CacheMemcached CacheApc Xcache MyOptions can any one help me?
  6. when i edit/add product on backoffice,i want display some filter suppliers(use condition to display some supplier on php),which hook can do it? or any other way do it?
  7. hi,i want add new field on product list page,i register hook ActionProductGridDefinitionModifier. but not work.how change it?
  8. hi,if i want create new module like mymodule and i want install third party library on modules/mymodule/libraries/ but the third party library use composer install it like: composer require alibabacloud/alimt which is the best way to install it?just run the command?or other best way?thanks
  9. no, new OwnObject(primaryid) will be ok. i sure is $object = new OwnObject(); $object->id=primaryid; object->save();
  10. if i have own ObjectModule; fields and data is fields_id, fields_a, fields_b, fields_c, primary id is fields 1 11 11 11 2 22 22 22 now do this: $object=new OwnObject(); $object->id=2; $object->fields_b='222'; $object->save(); when exec save() function; fields_a and flelds_c will be 0
  11. hi,i have new module name is "etalimama" this is my tab code: $moduleName = $this->name; TabManager::addTab('AdminTaoBao', 'TaoBao', $moduleName, 'AdminTools'); i have admin controller on etalimama/controllers/admin/AdminTaoBaoController.php <?php //etalimama/controllers/admin/AdminTaoBaoController.php namespace EtAliMaMa\Controller\Admin; use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController; use PrestaShopBundle\Security\Annotation\AdminSecurity; use Symfony\Component\HttpFoundation\Response; class AdminTaoBaoController extends FrameworkBundleAdminController { /** * @see https://devdocs.prestashop.com/1.7/development/architecture/migration-guide/controller-routing/#security * @AdminSecurity( * "is_granted(['read'], request.get('_legacy_controller'))", * message="You do not have permission to access Exemple page." * ) * * @return Response */ public function indexAction() { return $this->render("@Modules/etalimama/views/templates/admin/index.html.twig"); } } then,this is my composer.json on etalimama/composer.json { "name": "prestashop/alimama", "description": "A module for etalimama", "autoload": { "psr-4": { "EtAliMaMa\\": "controllers/" } }, "license": "MIT", "type": "prestashop-module" } routes.yml on config/ etalimama_admin_index: path: etalimama methods: [GET] defaults: _controller: 'EtAliMaMa\Controller\Admin\AdminTaoBaoController::indexAction' _legacy_controller: 'AdminTaoBao' _legacy_link: AdminTaoBao i run command on modules/ and modules/etalimama/ composer dumpautoload when i view admin tab.then say: Class "EtAliMaMa\Controller\Admin\AdminTaoBaoController" does not exist. please tell me why?
×
×
  • Create New...