Giter Site home page Giter Site logo

Comments (2)

patrick-bigbridge avatar patrick-bigbridge commented on May 30, 2024

Hi Alex,

I understand your use case, and I appreciate your effort to extend the library, but their are some reasons why I do not want to include the fetching of data (yet).

The most important reason is that fetching attribute data of many products can best be done in a single query. And sometimes you need multiple attributes. Then there are store views to consider. In short, the most efficient way of fetching data differs per use case.

Second, to fetch data of all kinds of product attributes and other aspects is a lot of work. Now we could start by just building what we need, but in order to make this extendible in the future, a new class tree would need to be set up. I don't want to clutter the Product class with fetch methods, it is too far outside of its responsibility.

And last, there is a perfectly good way to fetch some data directly from the database: direct database access. For example in http://blog.chapagain.com.np/magento-2-run-custom-sql-query/

To conclude, currently I am reluctant to include fetching data into the library. If, however, more people need such functionality and the same type of product data requests keep occurring, we could make a exception for some special cases. I would then suggest the class Api/Information for this.

from product-import.

haelbichalex avatar haelbichalex commented on May 30, 2024

For anyone interested: I dealt with my issue by creating a new class and using the Magento2DbConnection provided by this project (because why not).

/**
 * @param \BigBridge\ProductImport\Model\Persistence\Magento2DbConnection $dbConnection
 */
public function __construct(
    \BigBridge\ProductImport\Model\Persistence\Magento2DbConnection $dbConnection
) {
    $this->dbConnection = $dbConnection;
}

And here I fetch the attributes value:

$this->dbConnection->fetchSingleCell("
    SELECT `value`
    FROM `catalog_product_entity_varchar`
    WHERE `attribute_id` = {$attributeId} AND `entity_id` = {$this->productId}
");

This either returns my desired value or null, what tells me I need to do an update.

from product-import.

Related Issues (20)

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.